rez_core 2.2.99 → 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.99",
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({
@@ -7,6 +7,7 @@ import { DataSource, EntityManager } from 'typeorm';
7
7
  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
+ import { MediaDataService } from 'src/module/meta/service/media-data.service';
10
11
 
11
12
  @Injectable()
12
13
  export class TaskService extends EntityServiceImpl {
@@ -16,6 +17,7 @@ export class TaskService extends EntityServiceImpl {
16
17
  private readonly dataSource: DataSource,
17
18
  @Inject('ActivityLogService')
18
19
  private readonly activityLogService: ActivityLogService,
20
+ private readonly mediaDataService: MediaDataService,
19
21
  ) {
20
22
  super();
21
23
  }
@@ -214,13 +216,14 @@ export class TaskService extends EntityServiceImpl {
214
216
  s.name AS stage_name,
215
217
  a.name AS action_name,
216
218
  u.name AS created_by_name,
217
- u2.name AS task_owner_name
219
+ u2.name AS task_owner_name,
220
+ u2.profile_image AS task_owner_profile
218
221
  FROM cr_wf_task_data t
219
222
  LEFT JOIN cr_wf_stage s ON t.stage_id = s.id
220
223
  LEFT JOIN cr_wf_stage_group sg ON s.stage_group_id = sg.id
221
224
  LEFT JOIN cr_wf_action a ON t.action_id = a.id
222
225
  LEFT JOIN cr_user u ON t.created_by = u.id
223
- LEFT JOIN cr_user u2 ON t.task_owner = u2.id
226
+ LEFT JOIN eth_user_profile u2 ON t.task_owner = u2.parent_id
224
227
  WHERE ${whereClauses.join(' AND ')}
225
228
  ORDER BY t.created_date DESC
226
229
  `;
@@ -248,15 +251,34 @@ export class TaskService extends EntityServiceImpl {
248
251
  );
249
252
 
250
253
  // Assign task_status using the map
254
+
255
+ const mediaCache = new Map<number, any>();
256
+
251
257
  for (const task of taskData) {
258
+ // Map status name
252
259
  task.task_status = task.status
253
260
  ? statusMap.get(String(task.status)) || null
254
261
  : null;
255
262
 
263
+ // Fix action_name for generic tasks
256
264
  task.action_name =
257
265
  task.action_id === '0' || task.action_id === 0
258
266
  ? 'Generic'
259
267
  : task.action_name;
268
+
269
+ // Profile media (with caching like notes)
270
+ if (task.task_owner_profile) {
271
+ if (!mediaCache.has(task.task_owner_profile)) {
272
+ const url = await this.mediaDataService.getMediaDownloadUrl(
273
+ task.task_owner_profile,
274
+ loggedInUser,
275
+ );
276
+ mediaCache.set(task.task_owner_profile, url);
277
+ }
278
+ task.task_owner_profile = mediaCache.get(task.task_owner_profile);
279
+ } else {
280
+ task.task_owner_profile = null;
281
+ }
260
282
  }
261
283
 
262
284
  // Normalize is_mandatory to '0'/'1' as string