rez_core 5.0.141 → 5.0.142

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": "5.0.141",
3
+ "version": "5.0.142",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -3,6 +3,8 @@ import { GenericMessageDto, IntegrationService } from './integration.service';
3
3
  import { IcsMeetingService } from 'src/module/ics/service/ics.service';
4
4
  import { LoggingService } from 'src/utils/service/loggingUtil.service';
5
5
  import { ReflectionHelper } from '../../../utils/service/reflection-helper.service';
6
+ import { MediaDataService } from 'src/module/meta/service/media-data.service';
7
+ import axios from 'axios';
6
8
 
7
9
  @Injectable()
8
10
  export class WrapperService {
@@ -13,6 +15,7 @@ export class WrapperService {
13
15
  private readonly icsService: IcsMeetingService,
14
16
  private readonly loggingService: LoggingService,
15
17
  private readonly reflectionHelper: ReflectionHelper,
18
+ private readonly mediaService: MediaDataService,
16
19
  ) {}
17
20
 
18
21
  /**
@@ -405,6 +408,40 @@ export class WrapperService {
405
408
  [],
406
409
  );
407
410
 
411
+ // attachments: [1, 2, 3, 4]
412
+
413
+ if (entity.attachments && entity.attachments.length > 0) {
414
+ mailPayload.attachments = [];
415
+
416
+ for (const attachmentId of entity.attachments) {
417
+ // Step 1: Download or get media file
418
+ const url = await this.mediaService.getMediaDownloadUrl(
419
+ attachmentId,
420
+ {},
421
+ 60000,
422
+ );
423
+
424
+ if (!url?.signedUrl) continue;
425
+
426
+ // Step 2: Fetch file content
427
+ const response = await axios.get(url.signedUrl, {
428
+ responseType: 'arraybuffer',
429
+ });
430
+
431
+ // Step 3: Convert to base64
432
+ const base64Content = Buffer.from(response.data).toString('base64');
433
+
434
+ // Step 4: Push formatted attachment
435
+ mailPayload.attachments.push({
436
+ content: base64Content,
437
+ type:
438
+ response.headers['content-type'] || 'application/octet-stream',
439
+ filename: `attachment-${attachmentId}`,
440
+ disposition: 'attachment',
441
+ });
442
+ }
443
+ }
444
+
408
445
  // Step 5️⃣ Send via Integration Service
409
446
  const result =
410
447
  await this.integrationService.sendGenericMessage(mailPayload);
@@ -129,6 +129,17 @@ export class MediaDataService extends EntityServiceImpl {
129
129
  jpg: 'image/jpeg',
130
130
  jpeg: 'image/jpeg',
131
131
  png: 'image/png',
132
+ gif: 'image/gif',
133
+ webp: 'image/webp',
134
+ txt: 'text/plain',
135
+ html: 'text/html',
136
+ htm: 'text/html',
137
+ doc: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
138
+ docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
139
+ xls: 'application/vnd.ms-excel',
140
+ xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
141
+ ppt: 'application/vnd.ms-powerpoint',
142
+ pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
132
143
  };
133
144
  return map[ext] || 'application/octet-stream';
134
145
  }