rez_core 2.2.198 → 2.2.200

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 (32) hide show
  1. package/dist/module/communication/service/communication.service.js +1 -1
  2. package/dist/module/communication/service/communication.service.js.map +1 -1
  3. package/dist/module/communication/service/wrapper.service.js +3 -3
  4. package/dist/module/communication/service/wrapper.service.js.map +1 -1
  5. package/dist/module/notification/controller/otp.controller.d.ts +2 -1
  6. package/dist/module/notification/controller/otp.controller.js +19 -3
  7. package/dist/module/notification/controller/otp.controller.js.map +1 -1
  8. package/dist/module/notification/service/otp.service.d.ts +3 -0
  9. package/dist/module/notification/service/otp.service.js +7 -4
  10. package/dist/module/notification/service/otp.service.js.map +1 -1
  11. package/dist/module/user/entity/user.entity.d.ts +3 -0
  12. package/dist/module/user/entity/user.entity.js +12 -0
  13. package/dist/module/user/entity/user.entity.js.map +1 -1
  14. package/dist/module/user/service/login.service.d.ts +3 -0
  15. package/dist/module/user/service/login.service.js +11 -1
  16. package/dist/module/user/service/login.service.js.map +1 -1
  17. package/dist/module/workflow/entity/comm-template.entity.d.ts +1 -0
  18. package/dist/module/workflow/entity/comm-template.entity.js +4 -0
  19. package/dist/module/workflow/entity/comm-template.entity.js.map +1 -1
  20. package/dist/module/workflow/service/task.service.d.ts +1 -3
  21. package/dist/module/workflow/service/task.service.js +2 -5
  22. package/dist/module/workflow/service/task.service.js.map +1 -1
  23. package/dist/tsconfig.build.tsbuildinfo +1 -1
  24. package/package.json +2 -1
  25. package/src/module/communication/service/communication.service.ts +4 -1
  26. package/src/module/communication/service/wrapper.service.ts +3 -3
  27. package/src/module/notification/controller/otp.controller.ts +22 -1
  28. package/src/module/notification/service/otp.service.ts +11 -4
  29. package/src/module/user/entity/user.entity.ts +9 -0
  30. package/src/module/user/service/login.service.ts +27 -1
  31. package/src/module/workflow/entity/comm-template.entity.ts +3 -0
  32. package/src/module/workflow/service/task.service.ts +0 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "2.2.198",
3
+ "version": "2.2.200",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -62,6 +62,7 @@
62
62
  "rxjs": "^7.8.1",
63
63
  "twilio": "^5.9.0",
64
64
  "typeorm": "^0.3.20",
65
+ "ua-parser-js": "^2.0.5",
65
66
  "uuid": "^11.1.0",
66
67
  "winston": "^3.17.0",
67
68
  "xlsx": "^0.18.5"
@@ -923,7 +923,10 @@ export class CommunicationService {
923
923
  // Process template if provided
924
924
  let processedMessage = message;
925
925
  if (templateId && variables) {
926
- processedMessage = this.processTemplate(message, variables);
926
+ processedMessage = this.processTemplate(
927
+ html ? html : message,
928
+ variables,
929
+ );
927
930
  }
928
931
 
929
932
  // Merge config with enhanced parameters
@@ -40,12 +40,12 @@ export class WrapperService {
40
40
  if (payload.templateCode) {
41
41
  // Try current level first
42
42
  const template = await this.datasource.query(
43
- `SELECT code FROM cr_wf_comm_template WHERE code = ? AND level_id = ? AND level_type = ? LIMIT 1`,
43
+ `SELECT rich_text FROM cr_wf_comm_template WHERE code = ? AND level_id = ? AND level_type = ? LIMIT 1`,
44
44
  [payload.templateCode, level_id, level_type],
45
45
  );
46
46
 
47
47
  if (template && template.length > 0) {
48
- templateCode = template[0].code;
48
+ templateCode = template[0].rich_text;
49
49
  } else {
50
50
  // Fallback → ORG level
51
51
  const fallbackTemplate = await this.datasource.query(
@@ -75,7 +75,7 @@ export class WrapperService {
75
75
  type: 'EMAIL',
76
76
  cc: payload.cc,
77
77
  bcc: payload.bcc,
78
- html: payload.html,
78
+ html: templateCode,
79
79
  attachments: payload.attachments,
80
80
  templateId: templateCode,
81
81
  variables: payload.variables,
@@ -7,10 +7,13 @@ import {
7
7
  HttpStatus,
8
8
  Post,
9
9
  Query,
10
+ Req,
10
11
  } from '@nestjs/common';
11
12
  import { OtpService } from '../service/otp.service';
12
13
  import { ConfigService } from '@nestjs/config';
13
14
  import { EmailService } from '../service/email.service';
15
+ import { UAParser } from 'ua-parser-js';
16
+ import { Request } from 'express';
14
17
 
15
18
  @Controller('otp')
16
19
  export class OtpController {
@@ -52,8 +55,26 @@ export class OtpController {
52
55
  subdomain: string;
53
56
  fcm_token: string;
54
57
  },
58
+ @Req() req: Request,
55
59
  ) {
56
- return await this.otpService.verifyOtp(data);
60
+ const ip =
61
+ (req.headers['x-forwarded-for'] as string)?.split(',')[0].trim() ||
62
+ req.socket.remoteAddress ||
63
+ req.ip ||
64
+ '';
65
+
66
+ const userAgent = req.headers['user-agent'] || '';
67
+ const parser = new UAParser(userAgent);
68
+ const browser = parser.getBrowser().name || 'Unknown';
69
+ const os = parser.getOS().name || 'Unknown';
70
+
71
+ console.log('data', userAgent, parser, browser, os);
72
+ return await this.otpService.verifyOtp({
73
+ ...data,
74
+ ip,
75
+ browser,
76
+ os,
77
+ });
57
78
  }
58
79
 
59
80
  @Post('send-mail')
@@ -59,8 +59,12 @@ export class OtpService {
59
59
  identifier: string;
60
60
  subdomain: string;
61
61
  fcm_token: string;
62
+ browser?: string;
63
+ ip?: string;
64
+ os?: string;
62
65
  }) {
63
- const { otp, otp_id, identifier, subdomain, fcm_token } = data;
66
+ const { otp, otp_id, identifier, subdomain, fcm_token, browser, ip, os } =
67
+ data;
64
68
  const verifyOTPResponse = { isValid: false };
65
69
 
66
70
  // Find OTP entity by ID
@@ -100,10 +104,13 @@ export class OtpService {
100
104
 
101
105
  // Proceed to login
102
106
  return this.loginService.login({
103
- email: data.identifier,
107
+ email: identifier,
104
108
  is_otp: true,
105
- subdomain: data.subdomain,
106
- fcm_token: data.fcm_token,
109
+ subdomain,
110
+ fcm_token,
111
+ browser,
112
+ ip,
113
+ os,
107
114
  });
108
115
  }
109
116
 
@@ -56,4 +56,13 @@ export class UserData extends BaseEntity {
56
56
 
57
57
  @Column({ type: 'varchar', nullable: true })
58
58
  fcm_token: string;
59
+
60
+ @Column({ type: 'varchar', nullable: true })
61
+ browser: string;
62
+
63
+ @Column({ type: 'varchar', nullable: true })
64
+ ip: string;
65
+
66
+ @Column({ type: 'varchar', nullable: true })
67
+ os: string;
59
68
  }
@@ -44,11 +44,25 @@ export class LoginService {
44
44
  subdomain: string;
45
45
  fcm_token: string;
46
46
  is_otp?: boolean;
47
+ browser?: string;
48
+ ip?: string;
49
+ os?: string;
47
50
  }) {
48
- const { email, password, is_otp = false, subdomain, fcm_token } = data;
51
+ const {
52
+ email,
53
+ password,
54
+ is_otp = false,
55
+ subdomain,
56
+ fcm_token,
57
+ browser,
58
+ ip,
59
+ os,
60
+ } = data;
49
61
 
50
62
  let organization;
51
63
 
64
+ console.log('data', data);
65
+
52
66
  // 🔹 Step 1: If subdomain is provided, resolve the organization
53
67
  if (subdomain) {
54
68
  organization =
@@ -72,6 +86,18 @@ export class LoginService {
72
86
  await this.userRepository.update({ id: user.id }, { fcm_token });
73
87
  }
74
88
 
89
+ if (browser) {
90
+ await this.userRepository.update({ id: user.id }, { browser });
91
+ }
92
+
93
+ if (ip) {
94
+ await this.userRepository.update({ id: user.id }, { ip });
95
+ }
96
+
97
+ if (os) {
98
+ await this.userRepository.update({ id: user.id }, { os });
99
+ }
100
+
75
101
  // 🔹 Step 3: Verify org status
76
102
  const userOrgData = await this.organizationRepository.findOrganizationById(
77
103
  user.organization_id,
@@ -34,4 +34,7 @@ export class CommTemplate extends BaseEntity {
34
34
 
35
35
  @Column({ type: 'varchar', nullable: true })
36
36
  flag: string;
37
+
38
+ @Column({ type: 'varchar', nullable: true })
39
+ template_id: string;
37
40
  }
@@ -8,8 +8,6 @@ import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
8
8
  import { ActivityLogService } from './activity-log.service';
9
9
  import { ACTIVITY_CATEGORIES } from '../repository/activity-log.repository';
10
10
  import { MediaDataService } from 'src/module/meta/service/media-data.service';
11
- // import { Cron, CronExpression } from '@nestjs/schedule';
12
- import { NotificationsService } from 'src/module/notification/service/notification.service';
13
11
 
14
12
  @Injectable()
15
13
  export class TaskService extends EntityServiceImpl {
@@ -20,7 +18,6 @@ export class TaskService extends EntityServiceImpl {
20
18
  @Inject('ActivityLogService')
21
19
  private readonly activityLogService: ActivityLogService,
22
20
  private readonly mediaDataService: MediaDataService,
23
- private readonly notificationsService: NotificationsService, // 👈 inject here
24
21
  ) {
25
22
  super();
26
23
  }