easywork-common-lib 1.0.250 → 1.0.253
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/entities/drive/file.entity.d.ts +1 -0
- package/dist/entities/drive/file.entity.js +6 -0
- package/dist/entities/drive/file.entity.js.map +1 -1
- package/dist/modules/queue/notifier.service.d.ts +4 -9
- package/dist/modules/queue/notifier.service.js +8 -170
- package/dist/modules/queue/notifier.service.js.map +1 -1
- package/dist/modules/queue/queue.module.js +4 -1
- package/dist/modules/queue/queue.module.js.map +1 -1
- package/dist/modules/queue/subservices/calendar.service.d.ts +2 -0
- package/dist/modules/queue/subservices/calendar.service.js +17 -0
- package/dist/modules/queue/subservices/calendar.service.js.map +1 -0
- package/dist/modules/queue/subservices/contact.service.d.ts +7 -0
- package/dist/modules/queue/subservices/contact.service.js +49 -0
- package/dist/modules/queue/subservices/contact.service.js.map +1 -0
- package/dist/modules/queue/subservices/index.d.ts +3 -0
- package/dist/modules/queue/subservices/index.js +20 -0
- package/dist/modules/queue/subservices/index.js.map +1 -0
- package/dist/modules/queue/subservices/task.service.d.ts +12 -0
- package/dist/modules/queue/subservices/task.service.js +173 -0
- package/dist/modules/queue/subservices/task.service.js.map +1 -0
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -24,6 +24,7 @@ let File = class File extends database_1.BaseEntityWithUser {
|
|
|
24
24
|
mimeType;
|
|
25
25
|
s3Key;
|
|
26
26
|
isDefault;
|
|
27
|
+
isTemporary;
|
|
27
28
|
owners;
|
|
28
29
|
};
|
|
29
30
|
exports.File = File;
|
|
@@ -67,6 +68,11 @@ __decorate([
|
|
|
67
68
|
(0, typeorm_1.Column)({ default: false }),
|
|
68
69
|
__metadata("design:type", Boolean)
|
|
69
70
|
], File.prototype, "isDefault", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
(0, swagger_1.ApiProperty)({ type: Boolean, description: 'Is this a temporary file?', default: false }),
|
|
73
|
+
(0, typeorm_1.Column)({ default: false }),
|
|
74
|
+
__metadata("design:type", Boolean)
|
|
75
|
+
], File.prototype, "isTemporary", void 0);
|
|
70
76
|
__decorate([
|
|
71
77
|
(0, swagger_1.ApiProperty)({ type: () => [entity_file_entity_1.EntityFile], description: 'Entities that own the file' }),
|
|
72
78
|
(0, typeorm_1.OneToMany)(() => entity_file_entity_1.EntityFile, (entityFile) => entityFile.file, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.entity.js","sourceRoot":"","sources":["../../../src/entities/drive/file.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA2D;AAC3D,qDAA4C;AAC5C,qCAA+D;AAC/D,mDAAyC;AACzC,sEAA2D;AAC3D,6CAA8C;AAGvC,IAAM,IAAI,GAAV,MAAM,IAAK,SAAQ,6BAAkB;IAI1C,IAAI,CAAS;IAQb,MAAM,CAAS;IAIf,GAAG,CAAS;IAIZ,IAAI,CAAS;IAIb,QAAQ,CAAS;IAIjB,KAAK,CAAS;IAId,SAAS,CAAU;
|
|
1
|
+
{"version":3,"file":"file.entity.js","sourceRoot":"","sources":["../../../src/entities/drive/file.entity.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import { AmqpConnection } from "@golevelup/nestjs-rabbitmq";
|
|
2
2
|
import { SendNotificationDto } from "../../common";
|
|
3
|
-
import {
|
|
3
|
+
import { ContactNotifierService, TaskNotifierService } from "./subservices";
|
|
4
4
|
export declare class EasyNotifierService {
|
|
5
5
|
private readonly amqpConnection;
|
|
6
6
|
private readonly exchangeName;
|
|
7
7
|
private readonly routingKey;
|
|
8
|
-
|
|
8
|
+
readonly task: TaskNotifierService;
|
|
9
|
+
readonly contact: ContactNotifierService;
|
|
10
|
+
constructor(amqpConnection: AmqpConnection, exchangeName: string, routingKey: string, taskNotifier: TaskNotifierService, contactNotifier: ContactNotifierService);
|
|
9
11
|
sendNotification(data: SendNotificationDto): Promise<void>;
|
|
10
|
-
notifyTaskCompletion(task: Task, recipientsId: string[]): Promise<void>;
|
|
11
|
-
notifyTaskOverdue(task: Task, recipientsId: string[]): Promise<void>;
|
|
12
|
-
notifyTaskContinue(task: Task, recipientsId: string[]): Promise<void>;
|
|
13
|
-
notifyNewTask(task: Task, recipientsId: string[]): Promise<void>;
|
|
14
|
-
notifyTaskUpdate(task: Task, recipientsId: string[], changedFields: string[]): Promise<void>;
|
|
15
|
-
notifyNewComment(task: Task, comment: TaskComment, recipientsId: string[]): Promise<void>;
|
|
16
|
-
notifyNewCommentContact(contact: Contact, comment: ContactComment, recipientsId: string[]): Promise<void>;
|
|
17
12
|
sendOTPPhone(code: string, recipientsId: string[]): Promise<void>;
|
|
18
13
|
sendOTPEmail(code: string, recipientsId: string[]): Promise<void>;
|
|
19
14
|
}
|
|
@@ -16,188 +16,25 @@ exports.EasyNotifierService = void 0;
|
|
|
16
16
|
const nestjs_rabbitmq_1 = require("@golevelup/nestjs-rabbitmq");
|
|
17
17
|
const common_1 = require("@nestjs/common");
|
|
18
18
|
const common_2 = require("../../common");
|
|
19
|
+
const subservices_1 = require("./subservices");
|
|
19
20
|
const logger = new common_1.Logger("EasyNotifierService");
|
|
20
21
|
let EasyNotifierService = class EasyNotifierService {
|
|
21
22
|
amqpConnection;
|
|
22
23
|
exchangeName;
|
|
23
24
|
routingKey;
|
|
24
|
-
|
|
25
|
+
task;
|
|
26
|
+
contact;
|
|
27
|
+
constructor(amqpConnection, exchangeName, routingKey, taskNotifier, contactNotifier) {
|
|
25
28
|
this.amqpConnection = amqpConnection;
|
|
26
29
|
this.exchangeName = exchangeName;
|
|
27
30
|
this.routingKey = routingKey;
|
|
31
|
+
this.task = taskNotifier;
|
|
32
|
+
this.contact = contactNotifier;
|
|
28
33
|
}
|
|
29
34
|
async sendNotification(data) {
|
|
30
35
|
logger.debug(`Sending notification: ${JSON.stringify(data)}`);
|
|
31
36
|
await this.amqpConnection.publish(this.exchangeName, this.routingKey, data);
|
|
32
37
|
}
|
|
33
|
-
async notifyTaskCompletion(task, recipientsId) {
|
|
34
|
-
const metadata = {
|
|
35
|
-
taskId: task.id,
|
|
36
|
-
taskOwnerId: task.createdBy.id,
|
|
37
|
-
taskResponsibleId: task.responsible[0].id,
|
|
38
|
-
};
|
|
39
|
-
const notificationDto = {
|
|
40
|
-
title: "Task Completed",
|
|
41
|
-
content: `The task ${task.name} has been completed`,
|
|
42
|
-
recipientsId,
|
|
43
|
-
entityId: task.id,
|
|
44
|
-
channels: [common_2.NotificationChannel.APP],
|
|
45
|
-
category: common_2.NotificationCategory.TASK,
|
|
46
|
-
subCategory: common_2.NotificationSubcategory.TASK_COMPLETED,
|
|
47
|
-
metadata,
|
|
48
|
-
};
|
|
49
|
-
await this.sendNotification(notificationDto);
|
|
50
|
-
}
|
|
51
|
-
async notifyTaskOverdue(task, recipientsId) {
|
|
52
|
-
const metadata = {
|
|
53
|
-
taskId: task.id,
|
|
54
|
-
taskOwnerId: task.createdBy.id,
|
|
55
|
-
taskResponsibleId: task.responsible[0].id,
|
|
56
|
-
};
|
|
57
|
-
const notificationDto = {
|
|
58
|
-
title: "Task Overdue",
|
|
59
|
-
content: `La tarea [#${task.number}] - ${task.name} está atrasada`,
|
|
60
|
-
recipientsId,
|
|
61
|
-
entityId: task.id,
|
|
62
|
-
channels: [common_2.NotificationChannel.APP, common_2.NotificationChannel.SMS, common_2.NotificationChannel.PUSH],
|
|
63
|
-
category: common_2.NotificationCategory.TASK,
|
|
64
|
-
subCategory: common_2.NotificationSubcategory.TASK_OVERDUE,
|
|
65
|
-
metadata,
|
|
66
|
-
};
|
|
67
|
-
await this.sendNotification(notificationDto);
|
|
68
|
-
}
|
|
69
|
-
async notifyTaskContinue(task, recipientsId) {
|
|
70
|
-
const metadata = {
|
|
71
|
-
taskId: task.id,
|
|
72
|
-
taskOwnerId: task.createdBy.id,
|
|
73
|
-
taskResponsibleId: task.responsible[0].id,
|
|
74
|
-
};
|
|
75
|
-
const notificationDto = {
|
|
76
|
-
title: "Task Continue",
|
|
77
|
-
content: `La tarea #${task.number} - ${task.name}, ha sido reanudada`,
|
|
78
|
-
recipientsId,
|
|
79
|
-
entityId: task.id,
|
|
80
|
-
channels: [common_2.NotificationChannel.APP],
|
|
81
|
-
category: common_2.NotificationCategory.TASK,
|
|
82
|
-
subCategory: common_2.NotificationSubcategory.TASK_UPDATED,
|
|
83
|
-
metadata,
|
|
84
|
-
};
|
|
85
|
-
await this.sendNotification(notificationDto);
|
|
86
|
-
}
|
|
87
|
-
async notifyNewTask(task, recipientsId) {
|
|
88
|
-
const fechaLimite = task.deadline ? `<br/>Fecha Limite:${new Date(task.deadline)}` : ``;
|
|
89
|
-
const observadores = task.observers.length > 0 ? `<br/>Observadores: ${task.observers.map(observer => observer.username).join(", ")}` : ``;
|
|
90
|
-
const responsible = task.responsible.length > 0 ? `<br/>Persona Responsable: ${task.responsible.map(responsible => responsible.username).join(", ")}` : ``;
|
|
91
|
-
const participants = task.participants.length > 0 ? `<br/>Participantes: ${task.participants.map(participant => participant.username).join(", ")}` : ``;
|
|
92
|
-
const content = `Nueva Tarea agregada: <a href="/tools/tasks/task/${task.id}?show=true" style="color:blue">[${task.name}]</a>${responsible}${observadores}${participants}${fechaLimite}`;
|
|
93
|
-
const metadata = {
|
|
94
|
-
taskId: task.id,
|
|
95
|
-
taskOwnerId: task.createdBy.id,
|
|
96
|
-
taskResponsibleId: task.responsible[0].id,
|
|
97
|
-
};
|
|
98
|
-
const notificationDto = {
|
|
99
|
-
title: "New Task",
|
|
100
|
-
content,
|
|
101
|
-
recipientsId,
|
|
102
|
-
entityId: task.id,
|
|
103
|
-
channels: [common_2.NotificationChannel.APP, common_2.NotificationChannel.SMS, common_2.NotificationChannel.PUSH],
|
|
104
|
-
category: common_2.NotificationCategory.TASK,
|
|
105
|
-
subCategory: common_2.NotificationSubcategory.NEW_TASK,
|
|
106
|
-
metadata,
|
|
107
|
-
};
|
|
108
|
-
await this.sendNotification(notificationDto);
|
|
109
|
-
}
|
|
110
|
-
async notifyTaskUpdate(task, recipientsId, changedFields) {
|
|
111
|
-
const metadata = {
|
|
112
|
-
taskId: task.id,
|
|
113
|
-
taskOwnerId: task.createdBy.id,
|
|
114
|
-
taskResponsibleId: task.responsible[0].id,
|
|
115
|
-
};
|
|
116
|
-
const createNotificationDto = (content, recipients) => ({
|
|
117
|
-
title: "Task Update",
|
|
118
|
-
content,
|
|
119
|
-
recipientsId: recipients,
|
|
120
|
-
entityId: task.id,
|
|
121
|
-
channels: [common_2.NotificationChannel.APP, common_2.NotificationChannel.SMS, common_2.NotificationChannel.PUSH],
|
|
122
|
-
category: common_2.NotificationCategory.TASK,
|
|
123
|
-
subCategory: common_2.NotificationSubcategory.TASK_UPDATED,
|
|
124
|
-
metadata,
|
|
125
|
-
});
|
|
126
|
-
const taskLink = `<a href="/tools/tasks/task/${task.id}?show=true" style="color:blue">[${task.name}]</a>`;
|
|
127
|
-
let content = `Tarea #${task.number} - ${taskLink}`;
|
|
128
|
-
if (changedFields.length === 0) {
|
|
129
|
-
content += " - ha sido actualizada";
|
|
130
|
-
await this.sendNotification(createNotificationDto(content, recipientsId));
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
content += " - se actualizó:";
|
|
134
|
-
if (changedFields.includes("deadline")) {
|
|
135
|
-
if (task.deadline) {
|
|
136
|
-
const deadLine = new Date(task.deadline);
|
|
137
|
-
content += `<br/>Fecha Limite cambiada: ${deadLine.getDate()}/${deadLine.getMonth() + 1}/${deadLine.getFullYear()}`;
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
content += `<br/>Fecha Limite cambiada: Ninguna`;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
if (changedFields.includes("responsible")) {
|
|
144
|
-
content = `Se le asignó la tarea #${task.number} - ${taskLink}`;
|
|
145
|
-
await this.sendNotification(createNotificationDto(content, [task.responsible[0].id]));
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
if (changedFields.includes("name"))
|
|
149
|
-
content += `<br/>Nombre: ${task.name}`;
|
|
150
|
-
if (changedFields.includes("description"))
|
|
151
|
-
content += `<br/>Descripción: ${task.description}`;
|
|
152
|
-
if (changedFields.includes("status"))
|
|
153
|
-
content += `<br/>Estado: ${task.status}`;
|
|
154
|
-
await this.sendNotification(createNotificationDto(content, recipientsId));
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
async notifyNewComment(task, comment, recipientsId) {
|
|
158
|
-
const commentText = comment.comment.slice(0, 20);
|
|
159
|
-
const content = `${comment.createdBy.name} comentó en la tarea: <a href="/tools/tasks/task/${task.id}?show=true" style="color:#170f6b">[${task.name}]</a>. Texto del comentario: ${commentText}`;
|
|
160
|
-
const metadata = {
|
|
161
|
-
taskId: task.id,
|
|
162
|
-
commentId: comment.id,
|
|
163
|
-
taskOwnerId: task.createdBy.id,
|
|
164
|
-
commentOwnerId: comment.createdBy.id,
|
|
165
|
-
taskResponsibleId: task.responsible[0].id,
|
|
166
|
-
};
|
|
167
|
-
const notificationDto = {
|
|
168
|
-
title: "New Comment",
|
|
169
|
-
content,
|
|
170
|
-
recipientsId,
|
|
171
|
-
entityId: task.id,
|
|
172
|
-
channels: [common_2.NotificationChannel.APP, common_2.NotificationChannel.SMS, common_2.NotificationChannel.PUSH],
|
|
173
|
-
category: common_2.NotificationCategory.TASK,
|
|
174
|
-
subCategory: common_2.NotificationSubcategory.TASK_NEW_COMMNET,
|
|
175
|
-
metadata,
|
|
176
|
-
};
|
|
177
|
-
await this.sendNotification(notificationDto);
|
|
178
|
-
}
|
|
179
|
-
async notifyNewCommentContact(contact, comment, recipientsId) {
|
|
180
|
-
const commentText = comment.comment.slice(0, 20);
|
|
181
|
-
const content = `${comment.createdBy.name} comentó en el contacto: <a href="/sales/contacts/contact/${contact.id}?show=true" style="color:#170f6b">[${contact.name}]</a>. Texto del comentario: ${commentText}`;
|
|
182
|
-
const metadata = {
|
|
183
|
-
contactId: contact.id,
|
|
184
|
-
commentId: comment.id,
|
|
185
|
-
contactOwnerId: contact.createdBy?.id,
|
|
186
|
-
commentOwnerId: comment.createdBy?.id,
|
|
187
|
-
contactAssignedId: contact?.assignedBy?.id,
|
|
188
|
-
};
|
|
189
|
-
const notificationDto = {
|
|
190
|
-
title: "New Comment",
|
|
191
|
-
content,
|
|
192
|
-
recipientsId,
|
|
193
|
-
entityId: contact.id,
|
|
194
|
-
channels: [common_2.NotificationChannel.APP, common_2.NotificationChannel.SMS, common_2.NotificationChannel.PUSH],
|
|
195
|
-
category: common_2.NotificationCategory.CRM,
|
|
196
|
-
subCategory: common_2.NotificationSubcategory.CONTACT_NEW_COMMENT,
|
|
197
|
-
metadata,
|
|
198
|
-
};
|
|
199
|
-
await this.sendNotification(notificationDto);
|
|
200
|
-
}
|
|
201
38
|
async sendOTPPhone(code, recipientsId) {
|
|
202
39
|
const notificationDto = {
|
|
203
40
|
title: "OTP Code",
|
|
@@ -226,6 +63,7 @@ exports.EasyNotifierService = EasyNotifierService = __decorate([
|
|
|
226
63
|
(0, common_1.Injectable)(),
|
|
227
64
|
__param(1, (0, common_1.Inject)('EXCHANGE_NAME')),
|
|
228
65
|
__param(2, (0, common_1.Inject)('NOTIFIER_ROUTING_KEY')),
|
|
229
|
-
__metadata("design:paramtypes", [nestjs_rabbitmq_1.AmqpConnection, String, String
|
|
66
|
+
__metadata("design:paramtypes", [nestjs_rabbitmq_1.AmqpConnection, String, String, subservices_1.TaskNotifierService,
|
|
67
|
+
subservices_1.ContactNotifierService])
|
|
230
68
|
], EasyNotifierService);
|
|
231
69
|
//# sourceMappingURL=notifier.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifier.service.js","sourceRoot":"","sources":["../../../src/modules/queue/notifier.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gEAA4D;AAC5D,2CAA4D;AAC5D,yCAAuH;
|
|
1
|
+
{"version":3,"file":"notifier.service.js","sourceRoot":"","sources":["../../../src/modules/queue/notifier.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gEAA4D;AAC5D,2CAA4D;AAC5D,yCAAuH;AACvH,+CAA4E;AAE5E,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC,qBAAqB,CAAC,CAAC;AAG1C,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAKP;IACyB;IACO;IANrC,IAAI,CAAsB;IAC1B,OAAO,CAAyB;IAEhD,YACqB,cAA8B,EACL,YAAoB,EACb,UAAkB,EACnE,YAAiC,EACjC,eAAuC;QAJtB,mBAAc,GAAd,cAAc,CAAgB;QACL,iBAAY,GAAZ,YAAY,CAAQ;QACb,eAAU,GAAV,UAAU,CAAQ;QAInE,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,eAAe,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,IAAyB;QAC5C,MAAM,CAAC,KAAK,CAAC,yBAAyB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC9D,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAChF,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,IAAY,EAAE,YAAsB;QACnD,MAAM,eAAe,GAAwB;YACzC,KAAK,EAAE,UAAU;YACjB,OAAO,EAAE,8BAA8B,IAAI,EAAE;YAC7C,YAAY;YACZ,QAAQ,EAAE,CAAC,4BAAmB,CAAC,GAAG,CAAC;YACnC,QAAQ,EAAE,6BAAoB,CAAC,GAAG;YAClC,WAAW,EAAE,gCAAuB,CAAC,GAAG;SAC3C,CAAC;QAEF,MAAM,IAAI,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,IAAY,EAAE,YAAsB;QACnD,MAAM,eAAe,GAAwB;YACzC,KAAK,EAAE,UAAU;YACjB,OAAO,EAAE,IAAI;YACb,YAAY;YACZ,QAAQ,EAAE,CAAC,4BAAmB,CAAC,KAAK,CAAC;YACrC,QAAQ,EAAE,6BAAoB,CAAC,GAAG;YAClC,WAAW,EAAE,gCAAuB,CAAC,GAAG;SAC3C,CAAC;QAEF,MAAM,IAAI,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC;IACjD,CAAC;CACJ,CAAA;AA7CY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;IAOJ,WAAA,IAAA,eAAM,EAAC,eAAe,CAAC,CAAA;IACvB,WAAA,IAAA,eAAM,EAAC,sBAAsB,CAAC,CAAA;qCAFE,gCAAc,kBAGjC,iCAAmB;QAChB,oCAAsB;GATlC,mBAAmB,CA6C/B"}
|
|
@@ -12,6 +12,7 @@ const common_1 = require("@nestjs/common");
|
|
|
12
12
|
const notifier_service_1 = require("./notifier.service");
|
|
13
13
|
const nestjs_rabbitmq_1 = require("@golevelup/nestjs-rabbitmq");
|
|
14
14
|
const scheduler_service_1 = require("./scheduler.service");
|
|
15
|
+
const subservices_1 = require("./subservices");
|
|
15
16
|
let EasyQueueModule = EasyQueueModule_1 = class EasyQueueModule {
|
|
16
17
|
static register(exchangeName, rabbitMQUri, notificationRoutingKey, schedulerRoutingKey) {
|
|
17
18
|
return {
|
|
@@ -42,8 +43,10 @@ let EasyQueueModule = EasyQueueModule_1 = class EasyQueueModule {
|
|
|
42
43
|
},
|
|
43
44
|
notifier_service_1.EasyNotifierService,
|
|
44
45
|
scheduler_service_1.EasySchedulerService,
|
|
46
|
+
subservices_1.TaskNotifierService,
|
|
47
|
+
subservices_1.ContactNotifierService,
|
|
45
48
|
],
|
|
46
|
-
exports: [notifier_service_1.EasyNotifierService, scheduler_service_1.EasySchedulerService],
|
|
49
|
+
exports: [notifier_service_1.EasyNotifierService, scheduler_service_1.EasySchedulerService, subservices_1.TaskNotifierService, subservices_1.ContactNotifierService],
|
|
47
50
|
};
|
|
48
51
|
}
|
|
49
52
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.module.js","sourceRoot":"","sources":["../../../src/modules/queue/queue.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA+D;AAC/D,yDAAyD;AACzD,gEAA4D;AAC5D,2DAA2D;
|
|
1
|
+
{"version":3,"file":"queue.module.js","sourceRoot":"","sources":["../../../src/modules/queue/queue.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA+D;AAC/D,yDAAyD;AACzD,gEAA4D;AAC5D,2DAA2D;AAC3D,+CAA4E;AAIrE,IAAM,eAAe,uBAArB,MAAM,eAAe;IAC1B,MAAM,CAAC,QAAQ,CACb,YAAoB,EACpB,WAAmB,EACnB,sBAA8B,EAC9B,mBAA2B;QAE3B,OAAO;YACL,MAAM,EAAE,iBAAe;YACvB,OAAO,EAAE;gBACP,gCAAc,CAAC,OAAO,CAAC,gCAAc,EAAE;oBACrC,SAAS,EAAE;wBACT;4BACE,IAAI,EAAE,YAAY;4BAClB,IAAI,EAAE,OAAO;yBACd;qBACF;oBACD,GAAG,EAAE,WAAW;iBACjB,CAAC;aACH;YACD,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,eAAe;oBACxB,QAAQ,EAAE,YAAY;iBACvB;gBACD;oBACE,OAAO,EAAE,sBAAsB;oBAC/B,QAAQ,EAAE,sBAAsB;iBACjC;gBACD;oBACE,OAAO,EAAE,uBAAuB;oBAChC,QAAQ,EAAE,mBAAmB;iBAC9B;gBACD,sCAAmB;gBACnB,wCAAoB;gBACpB,iCAAmB;gBACnB,oCAAsB;aACvB;YACD,OAAO,EAAE,CAAC,sCAAmB,EAAE,wCAAoB,EAAE,iCAAmB,EAAE,oCAAsB,CAAC;SAClG,CAAC;IACJ,CAAC;CACF,CAAA;AAzCY,0CAAe;0BAAf,eAAe;IAF3B,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,eAAe,CAyC3B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.CalendarService = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
let CalendarService = class CalendarService {
|
|
12
|
+
};
|
|
13
|
+
exports.CalendarService = CalendarService;
|
|
14
|
+
exports.CalendarService = CalendarService = __decorate([
|
|
15
|
+
(0, common_1.Injectable)()
|
|
16
|
+
], CalendarService);
|
|
17
|
+
//# sourceMappingURL=calendar.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar.service.js","sourceRoot":"","sources":["../../../../src/modules/queue/subservices/calendar.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAGrC,IAAM,eAAe,GAArB,MAAM,eAAe;CAAG,CAAA;AAAlB,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;GACA,eAAe,CAAG"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EasyNotifierService } from '../notifier.service';
|
|
2
|
+
import { Contact, ContactComment } from '../../../entities';
|
|
3
|
+
export declare class ContactNotifierService {
|
|
4
|
+
private readonly parent;
|
|
5
|
+
constructor(parent: EasyNotifierService);
|
|
6
|
+
notifyNewCommentContact(contact: Contact, comment: ContactComment, recipientsId: string[]): Promise<void>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ContactNotifierService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const notifier_service_1 = require("../notifier.service");
|
|
15
|
+
const common_2 = require("../../../common");
|
|
16
|
+
let ContactNotifierService = class ContactNotifierService {
|
|
17
|
+
parent;
|
|
18
|
+
constructor(parent) {
|
|
19
|
+
this.parent = parent;
|
|
20
|
+
}
|
|
21
|
+
async notifyNewCommentContact(contact, comment, recipientsId) {
|
|
22
|
+
const commentText = comment.comment.slice(0, 20);
|
|
23
|
+
const content = `${comment.createdBy.name} comentó en el contacto: <a href="/sales/contacts/contact/${contact.id}?show=true" style="color:#170f6b">[${contact.name}]</a>. Texto del comentario: ${commentText}`;
|
|
24
|
+
const metadata = {
|
|
25
|
+
contactId: contact.id,
|
|
26
|
+
commentId: comment.id,
|
|
27
|
+
contactOwnerId: contact.createdBy?.id,
|
|
28
|
+
commentOwnerId: comment.createdBy?.id,
|
|
29
|
+
contactAssignedId: contact?.assignedBy?.id,
|
|
30
|
+
};
|
|
31
|
+
const notificationDto = {
|
|
32
|
+
title: "New Comment",
|
|
33
|
+
content,
|
|
34
|
+
recipientsId,
|
|
35
|
+
entityId: contact.id,
|
|
36
|
+
channels: [common_2.NotificationChannel.APP, common_2.NotificationChannel.SMS, common_2.NotificationChannel.PUSH],
|
|
37
|
+
category: common_2.NotificationCategory.CRM,
|
|
38
|
+
subCategory: common_2.NotificationSubcategory.CONTACT_NEW_COMMENT,
|
|
39
|
+
metadata,
|
|
40
|
+
};
|
|
41
|
+
await this.parent.sendNotification(notificationDto);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.ContactNotifierService = ContactNotifierService;
|
|
45
|
+
exports.ContactNotifierService = ContactNotifierService = __decorate([
|
|
46
|
+
(0, common_1.Injectable)(),
|
|
47
|
+
__metadata("design:paramtypes", [notifier_service_1.EasyNotifierService])
|
|
48
|
+
], ContactNotifierService);
|
|
49
|
+
//# sourceMappingURL=contact.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contact.service.js","sourceRoot":"","sources":["../../../../src/modules/queue/subservices/contact.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,0DAA0D;AAE1D,4CAA0H;AAGnH,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IACJ;IAA7B,YAA6B,MAA2B;QAA3B,WAAM,GAAN,MAAM,CAAqB;IAAG,CAAC;IAE5D,KAAK,CAAC,uBAAuB,CAAC,OAAgB,EAAE,OAAuB,EAAE,YAAsB;QAC7F,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACjD,MAAM,OAAO,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,6DAA6D,OAAO,CAAC,EAAE,sCAAsC,OAAO,CAAC,IAAI,gCAAgC,WAAW,EAAE,CAAC;QAEhN,MAAM,QAAQ,GAAG;YACb,SAAS,EAAE,OAAO,CAAC,EAAE;YACrB,SAAS,EAAE,OAAO,CAAC,EAAE;YACrB,cAAc,EAAE,OAAO,CAAC,SAAS,EAAE,EAAE;YACrC,cAAc,EAAE,OAAO,CAAC,SAAS,EAAE,EAAE;YACrC,iBAAiB,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE;SAC7C,CAAC;QAEF,MAAM,eAAe,GAAwB;YACzC,KAAK,EAAE,aAAa;YACpB,OAAO;YACP,YAAY;YACZ,QAAQ,EAAE,OAAO,CAAC,EAAE;YACpB,QAAQ,EAAE,CAAC,4BAAmB,CAAC,GAAG,EAAE,4BAAmB,CAAC,GAAG,EAAE,4BAAmB,CAAC,IAAI,CAAC;YACtF,QAAQ,EAAE,6BAAoB,CAAC,GAAG;YAClC,WAAW,EAAE,gCAAuB,CAAC,mBAAmB;YACxD,QAAQ;SACX,CAAC;QAEF,MAAM,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC;IACxD,CAAC;CACA,CAAA;AA5BY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;qCAE0B,sCAAmB;GAD7C,sBAAsB,CA4BlC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./contact.service"), exports);
|
|
18
|
+
__exportStar(require("./task.service"), exports);
|
|
19
|
+
__exportStar(require("./calendar.service"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/queue/subservices/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,iDAA+B;AAC/B,qDAAmC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EasyNotifierService } from '../notifier.service';
|
|
2
|
+
import { Task, TaskComment } from '../../../entities';
|
|
3
|
+
export declare class TaskNotifierService {
|
|
4
|
+
private readonly parent;
|
|
5
|
+
constructor(parent: EasyNotifierService);
|
|
6
|
+
notifyTaskCompletion(task: Task, recipientsId: string[]): Promise<void>;
|
|
7
|
+
notifyTaskOverdue(task: Task, recipientsId: string[]): Promise<void>;
|
|
8
|
+
notifyTaskContinue(task: Task, recipientsId: string[]): Promise<void>;
|
|
9
|
+
notifyNewTask(task: Task, recipientsId: string[]): Promise<void>;
|
|
10
|
+
notifyTaskUpdate(task: Task, recipientsId: string[], changedFields: string[]): Promise<void>;
|
|
11
|
+
notifyNewComment(task: Task, comment: TaskComment, recipientsId: string[]): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.TaskNotifierService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const notifier_service_1 = require("../notifier.service");
|
|
15
|
+
const common_2 = require("../../../common");
|
|
16
|
+
let TaskNotifierService = class TaskNotifierService {
|
|
17
|
+
parent;
|
|
18
|
+
constructor(parent) {
|
|
19
|
+
this.parent = parent;
|
|
20
|
+
}
|
|
21
|
+
async notifyTaskCompletion(task, recipientsId) {
|
|
22
|
+
const metadata = {
|
|
23
|
+
taskId: task.id,
|
|
24
|
+
taskOwnerId: task.createdBy.id,
|
|
25
|
+
taskResponsibleId: task.responsible[0].id,
|
|
26
|
+
};
|
|
27
|
+
const notificationDto = {
|
|
28
|
+
title: "Task Completed",
|
|
29
|
+
content: `The task ${task.name} has been completed`,
|
|
30
|
+
recipientsId,
|
|
31
|
+
entityId: task.id,
|
|
32
|
+
channels: [common_2.NotificationChannel.APP],
|
|
33
|
+
category: common_2.NotificationCategory.TASK,
|
|
34
|
+
subCategory: common_2.NotificationSubcategory.TASK_COMPLETED,
|
|
35
|
+
metadata,
|
|
36
|
+
};
|
|
37
|
+
await this.parent.sendNotification(notificationDto);
|
|
38
|
+
}
|
|
39
|
+
async notifyTaskOverdue(task, recipientsId) {
|
|
40
|
+
const metadata = {
|
|
41
|
+
taskId: task.id,
|
|
42
|
+
taskOwnerId: task.createdBy.id,
|
|
43
|
+
taskResponsibleId: task.responsible[0].id,
|
|
44
|
+
};
|
|
45
|
+
const notificationDto = {
|
|
46
|
+
title: "Task Overdue",
|
|
47
|
+
content: `La tarea [#${task.number}] - ${task.name} está atrasada`,
|
|
48
|
+
recipientsId,
|
|
49
|
+
entityId: task.id,
|
|
50
|
+
channels: [common_2.NotificationChannel.APP, common_2.NotificationChannel.SMS, common_2.NotificationChannel.PUSH],
|
|
51
|
+
category: common_2.NotificationCategory.TASK,
|
|
52
|
+
subCategory: common_2.NotificationSubcategory.TASK_OVERDUE,
|
|
53
|
+
metadata,
|
|
54
|
+
};
|
|
55
|
+
await this.parent.sendNotification(notificationDto);
|
|
56
|
+
}
|
|
57
|
+
async notifyTaskContinue(task, recipientsId) {
|
|
58
|
+
const metadata = {
|
|
59
|
+
taskId: task.id,
|
|
60
|
+
taskOwnerId: task.createdBy.id,
|
|
61
|
+
taskResponsibleId: task.responsible[0].id,
|
|
62
|
+
};
|
|
63
|
+
const notificationDto = {
|
|
64
|
+
title: "Task Continue",
|
|
65
|
+
content: `La tarea #${task.number} - ${task.name}, ha sido reanudada`,
|
|
66
|
+
recipientsId,
|
|
67
|
+
entityId: task.id,
|
|
68
|
+
channels: [common_2.NotificationChannel.APP],
|
|
69
|
+
category: common_2.NotificationCategory.TASK,
|
|
70
|
+
subCategory: common_2.NotificationSubcategory.TASK_UPDATED,
|
|
71
|
+
metadata,
|
|
72
|
+
};
|
|
73
|
+
await this.parent.sendNotification(notificationDto);
|
|
74
|
+
}
|
|
75
|
+
async notifyNewTask(task, recipientsId) {
|
|
76
|
+
const fechaLimite = task.deadline ? `<br/>Fecha Limite:${new Date(task.deadline)}` : ``;
|
|
77
|
+
const observadores = task.observers.length > 0 ? `<br/>Observadores: ${task.observers.map(observer => observer.username).join(", ")}` : ``;
|
|
78
|
+
const responsible = task.responsible.length > 0 ? `<br/>Persona Responsable: ${task.responsible.map(responsible => responsible.username).join(", ")}` : ``;
|
|
79
|
+
const participants = task.participants.length > 0 ? `<br/>Participantes: ${task.participants.map(participant => participant.username).join(", ")}` : ``;
|
|
80
|
+
const content = `Nueva Tarea agregada: <a href="/tools/tasks/task/${task.id}?show=true" style="color:blue">[${task.name}]</a>${responsible}${observadores}${participants}${fechaLimite}`;
|
|
81
|
+
const metadata = {
|
|
82
|
+
taskId: task.id,
|
|
83
|
+
taskOwnerId: task.createdBy.id,
|
|
84
|
+
taskResponsibleId: task.responsible[0].id,
|
|
85
|
+
};
|
|
86
|
+
const notificationDto = {
|
|
87
|
+
title: "New Task",
|
|
88
|
+
content,
|
|
89
|
+
recipientsId,
|
|
90
|
+
entityId: task.id,
|
|
91
|
+
channels: [common_2.NotificationChannel.APP, common_2.NotificationChannel.SMS, common_2.NotificationChannel.PUSH],
|
|
92
|
+
category: common_2.NotificationCategory.TASK,
|
|
93
|
+
subCategory: common_2.NotificationSubcategory.NEW_TASK,
|
|
94
|
+
metadata,
|
|
95
|
+
};
|
|
96
|
+
await this.parent.sendNotification(notificationDto);
|
|
97
|
+
}
|
|
98
|
+
async notifyTaskUpdate(task, recipientsId, changedFields) {
|
|
99
|
+
const metadata = {
|
|
100
|
+
taskId: task.id,
|
|
101
|
+
taskOwnerId: task.createdBy.id,
|
|
102
|
+
taskResponsibleId: task.responsible[0].id,
|
|
103
|
+
};
|
|
104
|
+
const createNotificationDto = (content, recipients) => ({
|
|
105
|
+
title: "Task Update",
|
|
106
|
+
content,
|
|
107
|
+
recipientsId: recipients,
|
|
108
|
+
entityId: task.id,
|
|
109
|
+
channels: [common_2.NotificationChannel.APP, common_2.NotificationChannel.SMS, common_2.NotificationChannel.PUSH],
|
|
110
|
+
category: common_2.NotificationCategory.TASK,
|
|
111
|
+
subCategory: common_2.NotificationSubcategory.TASK_UPDATED,
|
|
112
|
+
metadata,
|
|
113
|
+
});
|
|
114
|
+
const taskLink = `<a href="/tools/tasks/task/${task.id}?show=true" style="color:blue">[${task.name}]</a>`;
|
|
115
|
+
let content = `Tarea #${task.number} - ${taskLink}`;
|
|
116
|
+
if (changedFields.length === 0) {
|
|
117
|
+
content += " - ha sido actualizada";
|
|
118
|
+
await this.parent.sendNotification(createNotificationDto(content, recipientsId));
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
content += " - se actualizó:";
|
|
122
|
+
if (changedFields.includes("deadline")) {
|
|
123
|
+
if (task.deadline) {
|
|
124
|
+
const deadLine = new Date(task.deadline);
|
|
125
|
+
content += `<br/>Fecha Limite cambiada: ${deadLine.getDate()}/${deadLine.getMonth() + 1}/${deadLine.getFullYear()}`;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
content += `<br/>Fecha Limite cambiada: Ninguna`;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (changedFields.includes("responsible")) {
|
|
132
|
+
content = `Se le asignó la tarea #${task.number} - ${taskLink}`;
|
|
133
|
+
await this.parent.sendNotification(createNotificationDto(content, [task.responsible[0].id]));
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
if (changedFields.includes("name"))
|
|
137
|
+
content += `<br/>Nombre: ${task.name}`;
|
|
138
|
+
if (changedFields.includes("description"))
|
|
139
|
+
content += `<br/>Descripción: ${task.description}`;
|
|
140
|
+
if (changedFields.includes("status"))
|
|
141
|
+
content += `<br/>Estado: ${task.status}`;
|
|
142
|
+
await this.parent.sendNotification(createNotificationDto(content, recipientsId));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
async notifyNewComment(task, comment, recipientsId) {
|
|
146
|
+
const commentText = comment.comment.slice(0, 20);
|
|
147
|
+
const content = `${comment.createdBy.name} comentó en la tarea: <a href="/tools/tasks/task/${task.id}?show=true" style="color:#170f6b">[${task.name}]</a>. Texto del comentario: ${commentText}`;
|
|
148
|
+
const metadata = {
|
|
149
|
+
taskId: task.id,
|
|
150
|
+
commentId: comment.id,
|
|
151
|
+
taskOwnerId: task.createdBy.id,
|
|
152
|
+
commentOwnerId: comment.createdBy.id,
|
|
153
|
+
taskResponsibleId: task.responsible[0].id,
|
|
154
|
+
};
|
|
155
|
+
const notificationDto = {
|
|
156
|
+
title: "New Comment",
|
|
157
|
+
content,
|
|
158
|
+
recipientsId,
|
|
159
|
+
entityId: task.id,
|
|
160
|
+
channels: [common_2.NotificationChannel.APP, common_2.NotificationChannel.SMS, common_2.NotificationChannel.PUSH],
|
|
161
|
+
category: common_2.NotificationCategory.TASK,
|
|
162
|
+
subCategory: common_2.NotificationSubcategory.TASK_NEW_COMMNET,
|
|
163
|
+
metadata,
|
|
164
|
+
};
|
|
165
|
+
await this.parent.sendNotification(notificationDto);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
exports.TaskNotifierService = TaskNotifierService;
|
|
169
|
+
exports.TaskNotifierService = TaskNotifierService = __decorate([
|
|
170
|
+
(0, common_1.Injectable)(),
|
|
171
|
+
__metadata("design:paramtypes", [notifier_service_1.EasyNotifierService])
|
|
172
|
+
], TaskNotifierService);
|
|
173
|
+
//# sourceMappingURL=task.service.js.map
|