rez_core 3.1.114 → 3.1.116

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": "3.1.114",
3
+ "version": "3.1.116",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -787,7 +787,7 @@ export class IntegrationService {
787
787
 
788
788
  await this.configRepository.update(config.id, {
789
789
  config_json: updatedConfigJson,
790
- } as any);
790
+ });
791
791
  }
792
792
 
793
793
  // Handle default configuration logic (simplified for now)
@@ -804,6 +804,36 @@ export class IntegrationService {
804
804
  );
805
805
  }
806
806
 
807
+ if (config.integration_type === 'TELEPHONE') {
808
+ try {
809
+ // Extract DID from config (could be did, callerNumber, or fromNumber)
810
+ const did = config.config_json.did;
811
+
812
+ if (did) {
813
+
814
+ await this.entityMapperRepository.delete({integration_config_id: config.id})
815
+
816
+ const entityMapper = this.entityMapperRepository.create({
817
+ integration_config_id: config.id,
818
+ level_id: String(config.level_id),
819
+ level_type: config.level_type,
820
+ appcode: config.app_code,
821
+ did: did,
822
+ campaign_name: config.config_json.campaignName || null,
823
+ });
824
+
825
+ await this.entityMapperRepository.save(entityMapper);
826
+ this.logger.log(
827
+ `DID mapping created for TELEPHONE integration: ${did} for ${config.level_id} ${config.level_type}`,
828
+ );
829
+ }
830
+ } catch (error) {
831
+ this.logger.warn(
832
+ `Failed to create DID mapping for TELEPHONE integration: ${error.message}`,
833
+ );
834
+ }
835
+ }
836
+
807
837
  // Apply direct config updates if any
808
838
  const directUpdates: any = {};
809
839
  if (updateData.priority !== undefined)
@@ -26,20 +26,28 @@ export class NotificationsService {
26
26
  body: string,
27
27
  data?: Record<string, any>,
28
28
  ) {
29
+ // Utility to sanitize FCM data payload
30
+ const sanitizeFCMData = (
31
+ payload: Record<string, any>,
32
+ ): Record<string, string> =>
33
+ Object.fromEntries(
34
+ Object.entries(payload).map(([k, v]) => {
35
+ if (v === null || v === undefined) return [k, '']; // fallback for null/undefined
36
+ if (typeof v === 'object') return [k, JSON.stringify(v)]; // preserve structure
37
+ return [k, String(v)]; // numbers, booleans, strings
38
+ }),
39
+ );
40
+
29
41
  const message: admin.messaging.Message = {
30
42
  token,
31
43
  notification: { title, body }, // system notification
32
- data: data
33
- ? Object.fromEntries(
34
- Object.entries(data).map(([k, v]) => [k, v.toString()]),
35
- )
36
- : undefined, // FCM requires all values to be strings
44
+ data: data ? sanitizeFCMData(data) : undefined,
37
45
  };
38
46
 
39
47
  try {
40
48
  return await this.firebaseAdmin.messaging().send(message);
41
49
  } catch (error) {
42
- console.error(error);
50
+ console.error('Error sending FCM message:', error);
43
51
  throw error;
44
52
  }
45
53
  }