rez_core 2.2.100 → 2.2.101

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "2.2.100",
3
+ "version": "2.2.101",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -56,7 +56,8 @@ export class OtpController {
56
56
  body: {
57
57
  to: string;
58
58
  subject: string;
59
- templateCode: number;
59
+ message: string;
60
+ templateCode: string;
60
61
  payload: any;
61
62
  },
62
63
  ) {
@@ -64,6 +65,7 @@ export class OtpController {
64
65
  return await this.emailService.sendEmailWithDynamicTemplate(
65
66
  body.to,
66
67
  body.subject,
68
+ body.message,
67
69
  body.templateCode,
68
70
  body.payload,
69
71
  );
@@ -35,7 +35,8 @@ export class EmailService {
35
35
  async sendEmailWithDynamicTemplate(
36
36
  email: string,
37
37
  subject: string,
38
- templateCode: number,
38
+ templateCode: string,
39
+ message?: string,
39
40
  context?: any,
40
41
  ) {
41
42
  // retrieve the rich_text from the database table cr_wf_comm_template for the given templateCode
@@ -45,13 +46,21 @@ export class EmailService {
45
46
  .findOne({ where: { code: templateCode } });
46
47
 
47
48
  if (!template) {
48
- throw new Error(`Template with code ${templateCode} not found`);
49
+ return {
50
+ success: false,
51
+ message: `Template with code ${templateCode} not found`,
52
+ };
49
53
  }
50
54
 
51
55
  // Compile the template string with Handlebars
52
56
  const templateString = template.rich_text || '';
53
57
 
54
- const compiled = Handlebars.compile(templateString);
58
+ let compiled;
59
+ if (message) {
60
+ compiled = Handlebars.compile(message);
61
+ } else {
62
+ compiled = Handlebars.compile(templateString);
63
+ }
55
64
  const htmlContent = compiled(context);
56
65
 
57
66
  await this.mailerService.sendMail({