rez_core 2.2.20 → 2.2.21
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 +5 -5
- package/dist/module/notification/controller/otp.controller.js.map +1 -1
- package/dist/module/notification/service/email.service.d.ts +4 -2
- package/dist/module/notification/service/email.service.js +13 -3
- package/dist/module/notification/service/email.service.js.map +1 -1
- package/dist/module/workflow/service/action.service.js +2 -1
- package/dist/module/workflow/service/action.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 +14 -6
- package/src/module/notification/service/email.service.ts +19 -2
- package/src/module/workflow/service/action.service.ts +6 -1
package/package.json
CHANGED
|
@@ -54,15 +54,23 @@ export class OtpController {
|
|
|
54
54
|
return { message: 'OTP verified successfully!', success: true };
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
@
|
|
57
|
+
@Post('send-mail')
|
|
58
58
|
@HttpCode(HttpStatus.OK)
|
|
59
|
-
async sendMail(
|
|
59
|
+
async sendMail(
|
|
60
|
+
@Body()
|
|
61
|
+
body: {
|
|
62
|
+
to: string;
|
|
63
|
+
subject: string;
|
|
64
|
+
templateCode: number;
|
|
65
|
+
payload: any;
|
|
66
|
+
},
|
|
67
|
+
) {
|
|
60
68
|
// return await this.emailService.sendEmail(email, 'Harry', '123456');
|
|
61
69
|
return await this.emailService.sendEmailWithDynamicTemplate(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
70
|
+
body.to,
|
|
71
|
+
body.subject,
|
|
72
|
+
body.templateCode,
|
|
73
|
+
body.payload,
|
|
66
74
|
);
|
|
67
75
|
}
|
|
68
76
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
2
|
import { MailerService } from '@nestjs-modules/mailer';
|
|
3
3
|
import * as Handlebars from 'handlebars';
|
|
4
|
+
import { DataSource } from 'typeorm';
|
|
4
5
|
|
|
5
6
|
@Injectable()
|
|
6
7
|
export class EmailService {
|
|
7
|
-
constructor(
|
|
8
|
+
constructor(
|
|
9
|
+
private readonly mailerService: MailerService,
|
|
10
|
+
private readonly datasource: DataSource,
|
|
11
|
+
) {}
|
|
8
12
|
|
|
9
13
|
async sendEmail(email, name: string, otp: string) {
|
|
10
14
|
this.mailerService
|
|
@@ -24,9 +28,22 @@ export class EmailService {
|
|
|
24
28
|
async sendEmailWithDynamicTemplate(
|
|
25
29
|
email: string,
|
|
26
30
|
subject: string,
|
|
27
|
-
|
|
31
|
+
templateCode: number,
|
|
28
32
|
context?: any,
|
|
29
33
|
) {
|
|
34
|
+
// retrieve the rich_text from the database table cr_wf_comm_template for the given templateCode
|
|
35
|
+
|
|
36
|
+
const template = await this.datasource
|
|
37
|
+
.getRepository('cr_wf_comm_template')
|
|
38
|
+
.findOne({ where: { code: templateCode } });
|
|
39
|
+
|
|
40
|
+
if (!template) {
|
|
41
|
+
throw new Error(`Template with code ${templateCode} not found`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Compile the template string with Handlebars
|
|
45
|
+
const templateString = template.rich_text || '';
|
|
46
|
+
|
|
30
47
|
const compiled = Handlebars.compile(templateString);
|
|
31
48
|
const htmlContent = compiled(context);
|
|
32
49
|
|
|
@@ -141,7 +141,7 @@ export class ActionService extends EntityServiceImpl {
|
|
|
141
141
|
|
|
142
142
|
// delete existing template mappings for this action
|
|
143
143
|
await this.dataSource.query(
|
|
144
|
-
`DELETE FROM
|
|
144
|
+
`DELETE FROM cr_wf_action_resources_mapping WHERE stg_act_mapping_id = ? AND type = 'template'`,
|
|
145
145
|
[stageActionMappingData.id],
|
|
146
146
|
);
|
|
147
147
|
|
|
@@ -162,6 +162,11 @@ export class ActionService extends EntityServiceImpl {
|
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
+
await this.dataSource.query(
|
|
166
|
+
`DELETE FROM cr_wf_action_resources_mapping WHERE stg_act_mapping_id = ? AND type = 'form'`,
|
|
167
|
+
[stageActionMappingData.id],
|
|
168
|
+
);
|
|
169
|
+
|
|
165
170
|
if (form) {
|
|
166
171
|
const resourceMapping = {
|
|
167
172
|
stg_act_mapping_id: stageActionMappingData.id,
|