rez_core 2.2.188 → 2.2.190
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/module/communication/controller/communication.controller.d.ts +22 -2
- package/dist/module/communication/controller/communication.controller.js +79 -3
- package/dist/module/communication/controller/communication.controller.js.map +1 -1
- package/dist/module/communication/dto/create-config.dto.d.ts +12 -0
- package/dist/module/communication/dto/create-config.dto.js +36 -1
- package/dist/module/communication/dto/create-config.dto.js.map +1 -1
- package/dist/module/communication/service/communication.service.d.ts +2 -30
- package/dist/module/communication/service/communication.service.js +30 -73
- package/dist/module/communication/service/communication.service.js.map +1 -1
- package/dist/module/communication/strategies/email/sendgrid-api.strategy.d.ts +8 -0
- package/dist/module/communication/strategies/email/sendgrid-api.strategy.js +52 -0
- package/dist/module/communication/strategies/email/sendgrid-api.strategy.js.map +1 -1
- package/dist/module/ics/service/ics.service.d.ts +2 -3
- package/dist/module/ics/service/ics.service.js +41 -35
- package/dist/module/ics/service/ics.service.js.map +1 -1
- package/dist/module/listmaster/service/list-master.service.js +2 -4
- package/dist/module/listmaster/service/list-master.service.js.map +1 -1
- package/dist/module/notification/controller/notification.controller.d.ts +5 -1
- package/dist/module/notification/controller/notification.controller.js +16 -3
- package/dist/module/notification/controller/notification.controller.js.map +1 -1
- package/dist/module/notification/service/notification.service.d.ts +7 -1
- package/dist/module/notification/service/notification.service.js +27 -12
- package/dist/module/notification/service/notification.service.js.map +1 -1
- package/dist/module/workflow/controller/comm-template.controller.d.ts +1 -1
- package/dist/module/workflow/controller/comm-template.controller.js.map +1 -1
- package/dist/module/workflow/entity/task-data.entity.d.ts +2 -2
- package/dist/module/workflow/entity/task-data.entity.js +3 -3
- package/dist/module/workflow/entity/task-data.entity.js.map +1 -1
- package/dist/module/workflow/repository/comm-template.repository.d.ts +1 -1
- package/dist/module/workflow/repository/comm-template.repository.js +17 -11
- package/dist/module/workflow/repository/comm-template.repository.js.map +1 -1
- package/dist/module/workflow/service/comm-template.service.d.ts +1 -1
- package/dist/module/workflow/service/comm-template.service.js.map +1 -1
- package/dist/module/workflow/service/task.service.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/communication/controller/communication.controller.ts +96 -16
- package/src/module/communication/dto/create-config.dto.ts +26 -0
- package/src/module/communication/service/communication.service.ts +69 -128
- package/src/module/communication/strategies/email/sendgrid-api.strategy.ts +65 -0
- package/src/module/ics/service/ics.service.ts +49 -37
- package/src/module/listmaster/service/list-master.service.ts +3 -6
- package/src/module/notification/controller/notification.controller.ts +21 -3
- package/src/module/notification/service/notification.service.ts +45 -20
- package/src/module/workflow/controller/comm-template.controller.ts +1 -1
- package/src/module/workflow/entity/task-data.entity.ts +3 -3
- package/src/module/workflow/repository/comm-template.repository.ts +30 -19
- package/src/module/workflow/service/comm-template.service.ts +2 -2
- package/src/module/workflow/service/task.service.ts +1 -1
|
@@ -37,11 +37,24 @@ export class NotificationsService {
|
|
|
37
37
|
return this.sendToDevice(token, title, body);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
async getAllNotifications(
|
|
40
|
+
async getAllNotifications(
|
|
41
|
+
loggedInUser: any,
|
|
42
|
+
filterQuery?: {
|
|
43
|
+
is_read?: string;
|
|
44
|
+
},
|
|
45
|
+
) {
|
|
46
|
+
// if no filterQuery provided, return all notifications
|
|
41
47
|
const { id, level_id, level_type } = loggedInUser;
|
|
42
48
|
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
// Convert query param ("true"/"false") → SQL-friendly value (1/0)
|
|
50
|
+
let isReadFilter: number | undefined = undefined;
|
|
51
|
+
if (filterQuery && filterQuery.is_read !== undefined) {
|
|
52
|
+
const isReadBool = String(filterQuery.is_read).toLowerCase() === 'true';
|
|
53
|
+
isReadFilter = isReadBool ? 1 : 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Build query dynamically
|
|
57
|
+
let query = `
|
|
45
58
|
SELECT
|
|
46
59
|
n.*,
|
|
47
60
|
u.name AS user_name,
|
|
@@ -49,15 +62,24 @@ export class NotificationsService {
|
|
|
49
62
|
FROM cr_notification n
|
|
50
63
|
LEFT JOIN eth_user_profile u ON n.user_id = u.parent_id
|
|
51
64
|
WHERE n.user_id = ? AND n.level_id = ? AND n.level_type = ?
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
const params: any[] = [id, level_id, level_type];
|
|
68
|
+
|
|
69
|
+
if (isReadFilter !== undefined) {
|
|
70
|
+
query += ` AND n.is_read = ?`;
|
|
71
|
+
params.push(isReadFilter);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
query += ` ORDER BY n.created_date DESC`;
|
|
75
|
+
|
|
76
|
+
const notifications = await this.dataSource.query(query, params);
|
|
56
77
|
|
|
57
78
|
// Profile media enrichment
|
|
58
79
|
const mediaCache = new Map();
|
|
59
80
|
for (const notification of notifications) {
|
|
60
|
-
|
|
81
|
+
// Ensure is_read is returned as boolean
|
|
82
|
+
notification.is_read = !!notification.is_read;
|
|
61
83
|
|
|
62
84
|
if (notification.user_profile) {
|
|
63
85
|
if (!mediaCache.has(notification.user_profile)) {
|
|
@@ -73,18 +95,21 @@ export class NotificationsService {
|
|
|
73
95
|
}
|
|
74
96
|
}
|
|
75
97
|
|
|
76
|
-
// Batch update all fetched notifications
|
|
77
|
-
if (notifications.length > 0) {
|
|
78
|
-
await this.dataSource.query(
|
|
79
|
-
`
|
|
80
|
-
UPDATE cr_notification
|
|
81
|
-
SET is_read = 1
|
|
82
|
-
WHERE user_id = ? AND level_id = ? AND level_type = ?
|
|
83
|
-
`,
|
|
84
|
-
[id, level_id, level_type],
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
98
|
return notifications;
|
|
89
99
|
}
|
|
100
|
+
|
|
101
|
+
async markAllAsRead(loggedInUser: any) {
|
|
102
|
+
const { id, level_id, level_type } = loggedInUser;
|
|
103
|
+
|
|
104
|
+
const query = `
|
|
105
|
+
UPDATE cr_notification
|
|
106
|
+
SET is_read = 1
|
|
107
|
+
WHERE user_id = ? AND level_id = ? AND level_type = ? AND is_read = 0
|
|
108
|
+
`;
|
|
109
|
+
|
|
110
|
+
const params = [id, level_id, level_type];
|
|
111
|
+
|
|
112
|
+
const result = await this.dataSource.query(query, params);
|
|
113
|
+
return { success: true, affectedRows: result.affectedRows || 0 };
|
|
114
|
+
}
|
|
90
115
|
}
|
|
@@ -21,7 +21,7 @@ export class CommTemplateController {
|
|
|
21
21
|
async getTemplate(
|
|
22
22
|
@Req() req: Request & { user: any },
|
|
23
23
|
@Body('entity_type') entity_type: string,
|
|
24
|
-
@Body('action_id') action_id
|
|
24
|
+
@Body('action_id') action_id?: number,
|
|
25
25
|
) {
|
|
26
26
|
const loggedInUser = req.user.userData;
|
|
27
27
|
const result = this.commTemplateService.getAllCommTemplate(
|
|
@@ -56,7 +56,7 @@ export class TaskDataEntity extends BaseEntity {
|
|
|
56
56
|
@Column({ nullable: true })
|
|
57
57
|
due_date: Date;
|
|
58
58
|
|
|
59
|
-
@Column({ nullable: true, type: '
|
|
59
|
+
@Column({ nullable: true, type: 'varchar' })
|
|
60
60
|
due_time: string;
|
|
61
61
|
|
|
62
62
|
@Column({ nullable: true, type: 'varchar' })
|
|
@@ -69,8 +69,8 @@ export class TaskDataEntity extends BaseEntity {
|
|
|
69
69
|
category: string;
|
|
70
70
|
|
|
71
71
|
@Column({ nullable: true })
|
|
72
|
-
|
|
72
|
+
reminder_date: Date;
|
|
73
73
|
|
|
74
74
|
@Column({ nullable: true, type: 'varchar' })
|
|
75
|
-
|
|
75
|
+
reminder_time: string;
|
|
76
76
|
}
|
|
@@ -5,6 +5,7 @@ import { DataSource, Repository } from 'typeorm';
|
|
|
5
5
|
import { CommTemplate } from '../entity/comm-template.entity';
|
|
6
6
|
import { TemplateAttach } from '../entity/template-attach-mapper.entity';
|
|
7
7
|
import { MediaDataService } from 'src/module/meta/service/media-data.service';
|
|
8
|
+
import { ComplianceRegistrationInquiriesInstance } from 'twilio/lib/rest/trusthub/v1/complianceRegistrationInquiries';
|
|
8
9
|
|
|
9
10
|
@Injectable()
|
|
10
11
|
export class CommTemplateRepository {
|
|
@@ -19,40 +20,50 @@ export class CommTemplateRepository {
|
|
|
19
20
|
|
|
20
21
|
async getAllCommTemplate(
|
|
21
22
|
entity_type: string,
|
|
22
|
-
action_id
|
|
23
|
-
loggedInUser
|
|
23
|
+
action_id?: number,
|
|
24
|
+
loggedInUser?,
|
|
24
25
|
) {
|
|
25
26
|
const { organization_id } = loggedInUser;
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
let is_template: number | undefined;
|
|
29
|
+
|
|
30
|
+
// 1️⃣ Only check action_id if provided
|
|
31
|
+
if (action_id) {
|
|
32
|
+
const [actionResult] = await this.dataSource.query(
|
|
33
|
+
`SELECT is_template
|
|
29
34
|
FROM cr_wf_action
|
|
30
35
|
WHERE id = ? AND organization_id = ?
|
|
31
36
|
LIMIT 1`,
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
[action_id, organization_id],
|
|
38
|
+
);
|
|
34
39
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
if (!actionResult) {
|
|
41
|
+
throw new Error('Invalid action_id');
|
|
42
|
+
}
|
|
38
43
|
|
|
39
|
-
|
|
44
|
+
is_template = actionResult.is_template;
|
|
40
45
|
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
await this.dataSource.query(
|
|
47
|
+
`UPDATE cr_wf_comm_template
|
|
43
48
|
SET is_template = ?
|
|
44
49
|
WHERE mapped_entity_type = ?
|
|
45
50
|
AND organization_id = ?`,
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
[is_template, entity_type, organization_id],
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const whereCondition: any = {
|
|
56
|
+
mapped_entity_type: entity_type,
|
|
57
|
+
organization_id,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
if (typeof is_template !== 'undefined') {
|
|
61
|
+
whereCondition.is_template = is_template;
|
|
62
|
+
}
|
|
48
63
|
|
|
49
64
|
return this.commTemplateRepository.find({
|
|
50
65
|
select: ['name', 'code', 'mode', 'is_template'],
|
|
51
|
-
where:
|
|
52
|
-
mapped_entity_type: entity_type,
|
|
53
|
-
organization_id,
|
|
54
|
-
is_template,
|
|
55
|
-
},
|
|
66
|
+
where: whereCondition,
|
|
56
67
|
});
|
|
57
68
|
}
|
|
58
69
|
|
|
@@ -80,8 +80,8 @@ export class CommTemplateService extends EntityServiceImpl {
|
|
|
80
80
|
|
|
81
81
|
async getAllCommTemplate(
|
|
82
82
|
entity_type: string,
|
|
83
|
-
action_id
|
|
84
|
-
loggedInUser
|
|
83
|
+
action_id?: number,
|
|
84
|
+
loggedInUser?,
|
|
85
85
|
) {
|
|
86
86
|
const commTemplateData =
|
|
87
87
|
await this.commTemplateRepository.getAllCommTemplate(
|
|
@@ -442,7 +442,7 @@ export class TaskService extends EntityServiceImpl {
|
|
|
442
442
|
return await super.createEntity(notePayload, loggedInUser);
|
|
443
443
|
}
|
|
444
444
|
|
|
445
|
-
@Cron(CronExpression.
|
|
445
|
+
@Cron(CronExpression.EVERY_10_SECONDS)
|
|
446
446
|
async fetchTasksDueIn30Mins() {
|
|
447
447
|
const now = new Date();
|
|
448
448
|
const in30Min = new Date(now.getTime() + 30 * 60 * 1000);
|