easywork-common-lib 1.0.289 → 1.0.292

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.
Files changed (31) hide show
  1. package/dist/common/functions/cripto.d.ts +1 -0
  2. package/dist/common/functions/cripto.js +9 -0
  3. package/dist/common/functions/cripto.js.map +1 -0
  4. package/dist/common/functions/image.d.ts +3 -0
  5. package/dist/common/functions/image.js +15 -0
  6. package/dist/common/functions/image.js.map +1 -0
  7. package/dist/common/functions/index.d.ts +2 -0
  8. package/dist/{entities/easyapp → common/functions}/index.js +2 -1
  9. package/dist/common/functions/index.js.map +1 -0
  10. package/dist/common/index.d.ts +1 -0
  11. package/dist/common/index.js +1 -0
  12. package/dist/common/index.js.map +1 -1
  13. package/package.json +2 -1
  14. package/tsconfig.tsbuildinfo +1 -1
  15. package/dist/entities/easyapp/index.d.ts +0 -1
  16. package/dist/entities/easyapp/index.js.map +0 -1
  17. package/dist/entities/helpers/sales/contact/contact_sources.entity.d.ts +0 -5
  18. package/dist/entities/helpers/sales/contact/contact_sources.entity.js +0 -36
  19. package/dist/entities/helpers/sales/contact/contact_sources.entity.js.map +0 -1
  20. package/dist/entities/helpers/sales/contact/contact_types.entity.d.ts +0 -5
  21. package/dist/entities/helpers/sales/contact/contact_types.entity.js +0 -36
  22. package/dist/entities/helpers/sales/contact/contact_types.entity.js.map +0 -1
  23. package/dist/entities/helpers/sales/poliza/h_poliza_company.entity.d.ts +0 -5
  24. package/dist/entities/helpers/sales/poliza/h_poliza_company.entity.js +0 -30
  25. package/dist/entities/helpers/sales/poliza/h_poliza_company.entity.js.map +0 -1
  26. package/dist/modules/notifier/notifier.module.d.ts +0 -4
  27. package/dist/modules/notifier/notifier.module.js +0 -49
  28. package/dist/modules/notifier/notifier.module.js.map +0 -1
  29. package/dist/modules/notifier/notifier.service.d.ts +0 -19
  30. package/dist/modules/notifier/notifier.service.js +0 -231
  31. package/dist/modules/notifier/notifier.service.js.map +0 -1
@@ -1 +0,0 @@
1
- export * from "./filter-view.entity";
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/entities/easyapp/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC"}
@@ -1,5 +0,0 @@
1
- import { BaseEntity } from "../../../../common/database";
2
- export declare class ContactSource extends BaseEntity {
3
- name: string;
4
- isDefault: boolean;
5
- }
@@ -1,36 +0,0 @@
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.ContactSource = void 0;
13
- const database_1 = require("../../../../common/database");
14
- const class_validator_1 = require("class-validator");
15
- const typeorm_1 = require("typeorm");
16
- const swagger_1 = require("@nestjs/swagger");
17
- let ContactSource = class ContactSource extends database_1.BaseEntity {
18
- name;
19
- isDefault;
20
- };
21
- exports.ContactSource = ContactSource;
22
- __decorate([
23
- (0, swagger_1.ApiProperty)({ type: String, description: 'Name of the contact source', minLength: 3 }),
24
- (0, class_validator_1.MinLength)(3),
25
- (0, typeorm_1.Column)({ unique: true }),
26
- __metadata("design:type", String)
27
- ], ContactSource.prototype, "name", void 0);
28
- __decorate([
29
- (0, swagger_1.ApiProperty)({ type: Boolean, description: 'Is this the default contact source?', default: false }),
30
- (0, typeorm_1.Column)({ default: false }),
31
- __metadata("design:type", Boolean)
32
- ], ContactSource.prototype, "isDefault", void 0);
33
- exports.ContactSource = ContactSource = __decorate([
34
- (0, typeorm_1.Entity)()
35
- ], ContactSource);
36
- //# sourceMappingURL=contact_sources.entity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"contact_sources.entity.js","sourceRoot":"","sources":["../../../../../src/entities/helpers/sales/contact/contact_sources.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0DAAyD;AACzD,qDAA4C;AAC5C,qCAAyC;AACzC,6CAA8C;AAGvC,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,qBAAU;IAI3C,IAAI,CAAS;IAIb,SAAS,CAAU;CACpB,CAAA;AATY,sCAAa;AAIxB;IAHC,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,4BAA4B,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IACtF,IAAA,2BAAS,EAAC,CAAC,CAAC;IACZ,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;2CACZ;AAIb;IAFC,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,qCAAqC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAClG,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;gDACR;wBARR,aAAa;IADzB,IAAA,gBAAM,GAAE;GACI,aAAa,CASzB"}
@@ -1,5 +0,0 @@
1
- import { BaseEntity } from "../../../../common/database";
2
- export declare class ContactType extends BaseEntity {
3
- name: string;
4
- isDefault: boolean;
5
- }
@@ -1,36 +0,0 @@
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.ContactType = void 0;
13
- const database_1 = require("../../../../common/database");
14
- const class_validator_1 = require("class-validator");
15
- const typeorm_1 = require("typeorm");
16
- const swagger_1 = require("@nestjs/swagger");
17
- let ContactType = class ContactType extends database_1.BaseEntity {
18
- name;
19
- isDefault;
20
- };
21
- exports.ContactType = ContactType;
22
- __decorate([
23
- (0, swagger_1.ApiProperty)({ type: String, description: 'Name of the contact type', minLength: 3 }),
24
- (0, class_validator_1.MinLength)(3),
25
- (0, typeorm_1.Column)({ unique: true }),
26
- __metadata("design:type", String)
27
- ], ContactType.prototype, "name", void 0);
28
- __decorate([
29
- (0, swagger_1.ApiProperty)({ type: Boolean, description: 'Is this the default contact type?', default: false }),
30
- (0, typeorm_1.Column)({ default: false }),
31
- __metadata("design:type", Boolean)
32
- ], ContactType.prototype, "isDefault", void 0);
33
- exports.ContactType = ContactType = __decorate([
34
- (0, typeorm_1.Entity)()
35
- ], ContactType);
36
- //# sourceMappingURL=contact_types.entity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"contact_types.entity.js","sourceRoot":"","sources":["../../../../../src/entities/helpers/sales/contact/contact_types.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0DAAyD;AACzD,qDAA4C;AAC5C,qCAAyC;AACzC,6CAA8C;AAGvC,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,qBAAU;IAIzC,IAAI,CAAS;IAIb,SAAS,CAAU;CACpB,CAAA;AATY,kCAAW;AAItB;IAHC,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,0BAA0B,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IACpF,IAAA,2BAAS,EAAC,CAAC,CAAC;IACZ,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;yCACZ;AAIb;IAFC,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,mCAAmC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAChG,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;8CACR;sBARR,WAAW;IADvB,IAAA,gBAAM,GAAE;GACI,WAAW,CASvB"}
@@ -1,5 +0,0 @@
1
- import { BaseEntity } from "typeorm";
2
- export declare class PolizaCompany extends BaseEntity {
3
- id?: string;
4
- name: string;
5
- }
@@ -1,30 +0,0 @@
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.PolizaCompany = void 0;
13
- const typeorm_1 = require("typeorm");
14
- let PolizaCompany = class PolizaCompany extends typeorm_1.BaseEntity {
15
- id;
16
- name;
17
- };
18
- exports.PolizaCompany = PolizaCompany;
19
- __decorate([
20
- (0, typeorm_1.PrimaryGeneratedColumn)("uuid"),
21
- __metadata("design:type", String)
22
- ], PolizaCompany.prototype, "id", void 0);
23
- __decorate([
24
- (0, typeorm_1.Column)({ unique: true }),
25
- __metadata("design:type", String)
26
- ], PolizaCompany.prototype, "name", void 0);
27
- exports.PolizaCompany = PolizaCompany = __decorate([
28
- (0, typeorm_1.Entity)()
29
- ], PolizaCompany);
30
- //# sourceMappingURL=h_poliza_company.entity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"h_poliza_company.entity.js","sourceRoot":"","sources":["../../../../../src/entities/helpers/sales/poliza/h_poliza_company.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA8E;AAGvE,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,oBAAU;IAEzC,EAAE,CAAU;IAGZ,IAAI,CAAS;CAChB,CAAA;AANY,sCAAa;AAEtB;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;yCACnB;AAGZ;IADC,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;2CACZ;wBALJ,aAAa;IADzB,IAAA,gBAAM,GAAE;GACI,aAAa,CAMzB"}
@@ -1,4 +0,0 @@
1
- import { DynamicModule } from '@nestjs/common';
2
- export declare class EasyNotifierModule {
3
- static register(exchangeName: string, routingKey: string, rabbitMQUri: string): DynamicModule;
4
- }
@@ -1,49 +0,0 @@
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 EasyNotifierModule_1;
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.EasyNotifierModule = void 0;
11
- const common_1 = require("@nestjs/common");
12
- const notifier_service_1 = require("./notifier.service");
13
- const nestjs_rabbitmq_1 = require("@golevelup/nestjs-rabbitmq");
14
- let EasyNotifierModule = EasyNotifierModule_1 = class EasyNotifierModule {
15
- static register(exchangeName, routingKey, rabbitMQUri) {
16
- return {
17
- module: EasyNotifierModule_1,
18
- imports: [
19
- nestjs_rabbitmq_1.RabbitMQModule.forRoot(nestjs_rabbitmq_1.RabbitMQModule, {
20
- exchanges: [
21
- {
22
- name: exchangeName,
23
- type: 'topic',
24
- },
25
- ],
26
- uri: rabbitMQUri,
27
- }),
28
- ],
29
- providers: [
30
- {
31
- provide: 'EXCHANGE_NAME',
32
- useValue: exchangeName,
33
- },
34
- {
35
- provide: 'ROUTING_KEY',
36
- useValue: routingKey,
37
- },
38
- notifier_service_1.EasyNotifierService,
39
- ],
40
- exports: [notifier_service_1.EasyNotifierService],
41
- };
42
- }
43
- };
44
- exports.EasyNotifierModule = EasyNotifierModule;
45
- exports.EasyNotifierModule = EasyNotifierModule = EasyNotifierModule_1 = __decorate([
46
- (0, common_1.Global)(),
47
- (0, common_1.Module)({})
48
- ], EasyNotifierModule);
49
- //# sourceMappingURL=notifier.module.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"notifier.module.js","sourceRoot":"","sources":["../../../src/modules/notifier/notifier.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA+D;AAC/D,yDAAyD;AACzD,gEAA4D;AAIrD,IAAM,kBAAkB,0BAAxB,MAAM,kBAAkB;IAC3B,MAAM,CAAC,QAAQ,CAAC,YAAoB,EAAE,UAAkB,EAAE,WAAmB;QACzE,OAAO;YACH,MAAM,EAAE,oBAAkB;YAC1B,OAAO,EAAE;gBACL,gCAAc,CAAC,OAAO,CAAC,gCAAc,EAAE;oBACnC,SAAS,EAAE;wBACP;4BACI,IAAI,EAAE,YAAY;4BAClB,IAAI,EAAE,OAAO;yBAChB;qBACJ;oBACD,GAAG,EAAE,WAAW;iBACnB,CAAC;aACL;YACD,SAAS,EAAE;gBACP;oBACI,OAAO,EAAE,eAAe;oBACxB,QAAQ,EAAE,YAAY;iBACzB;gBACD;oBACI,OAAO,EAAE,aAAa;oBACtB,QAAQ,EAAE,UAAU;iBACvB;gBACD,sCAAmB;aACtB;YACD,OAAO,EAAE,CAAC,sCAAmB,CAAC;SACjC,CAAC;IACN,CAAC;CACJ,CAAA;AA7BY,gDAAkB;6BAAlB,kBAAkB;IAF9B,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,kBAAkB,CA6B9B"}
@@ -1,19 +0,0 @@
1
- import { AmqpConnection } from "@golevelup/nestjs-rabbitmq";
2
- import { SendNotificationDto } from "../../common";
3
- import { Contact, ContactComment, Task, TaskComment } from "../../entities";
4
- export declare class EasyNotifierService {
5
- private readonly amqpConnection;
6
- private readonly exchangeName;
7
- private readonly routingKey;
8
- constructor(amqpConnection: AmqpConnection, exchangeName: string, routingKey: string);
9
- 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
- sendOTPPhone(code: string, recipientsId: string[]): Promise<void>;
18
- sendOTPEmail(code: string, recipientsId: string[]): Promise<void>;
19
- }
@@ -1,231 +0,0 @@
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
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.EasyNotifierService = void 0;
16
- const nestjs_rabbitmq_1 = require("@golevelup/nestjs-rabbitmq");
17
- const common_1 = require("@nestjs/common");
18
- const common_2 = require("../../common");
19
- const logger = new common_1.Logger("EasyNotifierService");
20
- let EasyNotifierService = class EasyNotifierService {
21
- amqpConnection;
22
- exchangeName;
23
- routingKey;
24
- constructor(amqpConnection, exchangeName, routingKey) {
25
- this.amqpConnection = amqpConnection;
26
- this.exchangeName = exchangeName;
27
- this.routingKey = routingKey;
28
- }
29
- async sendNotification(data) {
30
- logger.debug(`Sending notification: ${JSON.stringify(data)}`);
31
- await this.amqpConnection.publish(this.exchangeName, this.routingKey, data);
32
- }
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
- async sendOTPPhone(code, recipientsId) {
202
- const notificationDto = {
203
- title: "OTP Code",
204
- content: `Easywork: Your OTP code is ${code}`,
205
- recipientsId,
206
- channels: [common_2.NotificationChannel.SMS],
207
- category: common_2.NotificationCategory.OTP,
208
- subCategory: common_2.NotificationSubcategory.OTP,
209
- };
210
- await this.sendNotification(notificationDto);
211
- }
212
- async sendOTPEmail(code, recipientsId) {
213
- const notificationDto = {
214
- title: "OTP Code",
215
- content: code,
216
- recipientsId,
217
- channels: [common_2.NotificationChannel.EMAIL],
218
- category: common_2.NotificationCategory.OTP,
219
- subCategory: common_2.NotificationSubcategory.OTP,
220
- };
221
- await this.sendNotification(notificationDto);
222
- }
223
- };
224
- exports.EasyNotifierService = EasyNotifierService;
225
- exports.EasyNotifierService = EasyNotifierService = __decorate([
226
- (0, common_1.Injectable)(),
227
- __param(1, (0, common_1.Inject)('EXCHANGE_NAME')),
228
- __param(2, (0, common_1.Inject)('ROUTING_KEY')),
229
- __metadata("design:paramtypes", [nestjs_rabbitmq_1.AmqpConnection, String, String])
230
- ], EasyNotifierService);
231
- //# sourceMappingURL=notifier.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"notifier.service.js","sourceRoot":"","sources":["../../../src/modules/notifier/notifier.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gEAA4D;AAC5D,2CAA4D;AAC5D,yCAAuH;AAGvH,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC,qBAAqB,CAAC,CAAC;AAG1C,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAEP;IACyB;IACF;IAH5C,YACqB,cAA8B,EACL,YAAoB,EACtB,UAAkB;QAFzC,mBAAc,GAAd,cAAc,CAAgB;QACL,iBAAY,GAAZ,YAAY,CAAQ;QACtB,eAAU,GAAV,UAAU,CAAQ;IAC1D,CAAC;IAEL,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,oBAAoB,CAAC,IAAU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