rez_core 2.2.182 → 2.2.184
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/notification/controller/otp.controller.d.ts +6 -1
- package/dist/module/notification/controller/otp.controller.js +1 -1
- package/dist/module/notification/controller/otp.controller.js.map +1 -1
- package/dist/module/notification/service/email.service.d.ts +4 -1
- package/dist/module/notification/service/email.service.js +11 -10
- package/dist/module/notification/service/email.service.js.map +1 -1
- package/dist/module/workflow/controller/comm-template.controller.d.ts +2 -1
- package/dist/module/workflow/controller/comm-template.controller.js +4 -3
- package/dist/module/workflow/controller/comm-template.controller.js.map +1 -1
- package/dist/module/workflow/entity/comm-template.entity.d.ts +1 -0
- package/dist/module/workflow/entity/comm-template.entity.js +4 -0
- package/dist/module/workflow/entity/comm-template.entity.js.map +1 -1
- package/dist/module/workflow/repository/comm-template.repository.d.ts +4 -3
- package/dist/module/workflow/repository/comm-template.repository.js +20 -5
- package/dist/module/workflow/repository/comm-template.repository.js.map +1 -1
- package/dist/module/workflow/service/comm-template.service.d.ts +2 -1
- package/dist/module/workflow/service/comm-template.service.js +3 -2
- package/dist/module/workflow/service/comm-template.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/notification/controller/otp.controller.ts +5 -1
- package/src/module/notification/service/email.service.ts +15 -16
- package/src/module/workflow/controller/comm-template.controller.ts +2 -0
- package/src/module/workflow/entity/comm-template.entity.ts +3 -0
- package/src/module/workflow/repository/comm-template.repository.ts +33 -4
- package/src/module/workflow/service/comm-template.service.ts +7 -1
package/package.json
CHANGED
|
@@ -62,6 +62,8 @@ export class OtpController {
|
|
|
62
62
|
@Body()
|
|
63
63
|
body: {
|
|
64
64
|
to: string;
|
|
65
|
+
cc: string;
|
|
66
|
+
bcc: string;
|
|
65
67
|
subject: string;
|
|
66
68
|
message: string;
|
|
67
69
|
templateCode: string;
|
|
@@ -72,8 +74,10 @@ export class OtpController {
|
|
|
72
74
|
return await this.emailService.sendEmailWithDynamicTemplate(
|
|
73
75
|
body.to,
|
|
74
76
|
body.subject,
|
|
75
|
-
body.message,
|
|
76
77
|
body.templateCode,
|
|
78
|
+
body.cc ? body.cc.split(',') : [],
|
|
79
|
+
body.bcc ? body.bcc.split(',') : [],
|
|
80
|
+
body.message,
|
|
77
81
|
body.payload,
|
|
78
82
|
{
|
|
79
83
|
title: 'Project Kickoff Meeting',
|
|
@@ -66,38 +66,32 @@ export class EmailService {
|
|
|
66
66
|
email: string,
|
|
67
67
|
subject: string,
|
|
68
68
|
templateCode: string,
|
|
69
|
+
cc: string[] = [],
|
|
70
|
+
bcc: string[] = [],
|
|
69
71
|
message?: string,
|
|
70
72
|
context?: any,
|
|
71
73
|
icsPayload?: any,
|
|
72
74
|
) {
|
|
73
75
|
// retrieve the rich_text from the database table cr_wf_comm_template for the given templateCode
|
|
74
|
-
|
|
75
76
|
const template = await this.datasource
|
|
76
77
|
.getRepository('cr_wf_comm_template')
|
|
77
78
|
.findOne({ where: { code: templateCode } });
|
|
78
79
|
|
|
79
80
|
if (!template) {
|
|
80
81
|
console.log(`Template with code ${templateCode} not found`);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
// };
|
|
82
|
+
return {
|
|
83
|
+
success: false,
|
|
84
|
+
message: `Template with code ${templateCode} not found`,
|
|
85
|
+
};
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
// Compile the template string with Handlebars
|
|
89
|
-
const templateString = template
|
|
90
|
-
|
|
91
|
-
let compiled;
|
|
92
|
-
if (message) {
|
|
93
|
-
compiled = Handlebars.compile(message);
|
|
94
|
-
} else {
|
|
95
|
-
compiled = Handlebars.compile(templateString);
|
|
96
|
-
}
|
|
89
|
+
const templateString = template.rich_text || '';
|
|
90
|
+
const compiled = Handlebars.compile(message || templateString);
|
|
97
91
|
const htmlContent = compiled(context);
|
|
98
92
|
|
|
93
|
+
// Attachments (ICS optional)
|
|
99
94
|
const attachments: any[] = [];
|
|
100
|
-
|
|
101
95
|
if (icsPayload) {
|
|
102
96
|
const icsBase64 = await this.icsService.generateIcs(icsPayload);
|
|
103
97
|
if (icsBase64) {
|
|
@@ -110,11 +104,16 @@ export class EmailService {
|
|
|
110
104
|
}
|
|
111
105
|
}
|
|
112
106
|
|
|
107
|
+
// Send the email
|
|
113
108
|
await this.mailerService.sendMail({
|
|
114
109
|
to: email,
|
|
115
|
-
|
|
110
|
+
cc: cc.length > 0 ? cc : undefined,
|
|
111
|
+
bcc: bcc.length > 0 ? bcc : undefined,
|
|
112
|
+
subject,
|
|
116
113
|
html: htmlContent,
|
|
117
114
|
attachments,
|
|
118
115
|
});
|
|
116
|
+
|
|
117
|
+
return { success: true, message: 'Email sent successfully' };
|
|
119
118
|
}
|
|
120
119
|
}
|
|
@@ -21,10 +21,12 @@ 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: number,
|
|
24
25
|
) {
|
|
25
26
|
const loggedInUser = req.user.userData;
|
|
26
27
|
const result = this.commTemplateService.getAllCommTemplate(
|
|
27
28
|
entity_type || '',
|
|
29
|
+
action_id,
|
|
28
30
|
loggedInUser,
|
|
29
31
|
);
|
|
30
32
|
return result;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Injectable, NotFoundException } from '@nestjs/common';
|
|
2
2
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
3
|
import { Workflow } from '../entity/workflow.entity';
|
|
4
|
-
import { Repository } from 'typeorm';
|
|
4
|
+
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';
|
|
@@ -14,15 +14,44 @@ export class CommTemplateRepository {
|
|
|
14
14
|
@InjectRepository(TemplateAttach)
|
|
15
15
|
private readonly templateAttachEntity: Repository<TemplateAttach>,
|
|
16
16
|
private readonly mediaDataService: MediaDataService,
|
|
17
|
+
private readonly dataSource: DataSource,
|
|
17
18
|
) {}
|
|
18
19
|
|
|
19
|
-
async getAllCommTemplate(
|
|
20
|
+
async getAllCommTemplate(
|
|
21
|
+
entity_type: string,
|
|
22
|
+
action_id: number,
|
|
23
|
+
loggedInUser,
|
|
24
|
+
) {
|
|
20
25
|
const { organization_id } = loggedInUser;
|
|
26
|
+
|
|
27
|
+
const [actionResult] = await this.dataSource.query(
|
|
28
|
+
`SELECT is_template
|
|
29
|
+
FROM cr_wf_action
|
|
30
|
+
WHERE id = ? AND organization_id = ?
|
|
31
|
+
LIMIT 1`,
|
|
32
|
+
[action_id, organization_id],
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
if (!actionResult) {
|
|
36
|
+
throw new Error('Invalid action_id');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const { is_template } = actionResult;
|
|
40
|
+
|
|
41
|
+
await this.dataSource.query(
|
|
42
|
+
`UPDATE cr_wf_comm_template
|
|
43
|
+
SET is_template = ?
|
|
44
|
+
WHERE mapped_entity_type = ?
|
|
45
|
+
AND organization_id = ?`,
|
|
46
|
+
[is_template, entity_type, organization_id],
|
|
47
|
+
);
|
|
48
|
+
|
|
21
49
|
return this.commTemplateRepository.find({
|
|
22
|
-
select: ['name', 'code', 'mode'],
|
|
50
|
+
select: ['name', 'code', 'mode', 'is_template'],
|
|
23
51
|
where: {
|
|
24
52
|
mapped_entity_type: entity_type,
|
|
25
|
-
organization_id
|
|
53
|
+
organization_id,
|
|
54
|
+
is_template,
|
|
26
55
|
},
|
|
27
56
|
});
|
|
28
57
|
}
|
|
@@ -78,10 +78,15 @@ export class CommTemplateService extends EntityServiceImpl {
|
|
|
78
78
|
return getTemplate;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
async getAllCommTemplate(
|
|
81
|
+
async getAllCommTemplate(
|
|
82
|
+
entity_type: string,
|
|
83
|
+
action_id: number,
|
|
84
|
+
loggedInUser,
|
|
85
|
+
) {
|
|
82
86
|
const commTemplateData =
|
|
83
87
|
await this.commTemplateRepository.getAllCommTemplate(
|
|
84
88
|
entity_type,
|
|
89
|
+
action_id,
|
|
85
90
|
loggedInUser,
|
|
86
91
|
);
|
|
87
92
|
|
|
@@ -89,6 +94,7 @@ export class CommTemplateService extends EntityServiceImpl {
|
|
|
89
94
|
value: item.code,
|
|
90
95
|
label: item.name,
|
|
91
96
|
mode: item.mode,
|
|
97
|
+
template: item.is_template,
|
|
92
98
|
}));
|
|
93
99
|
|
|
94
100
|
return response;
|