@smartico/public-api 0.0.219 → 0.0.221

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.
@@ -2510,6 +2510,24 @@ class SmarticoAPI {
2510
2510
  }
2511
2511
  return ENV_ID;
2512
2512
  }
2513
+ replaceDomains(obj) {
2514
+ const domains = {
2515
+ 'static4.smr.vc': 'd146b4m7rkvjkw.cloudfront.net',
2516
+ 'img4.smr.vc': 'dvm0p9vsezqr2.cloudfront.net'
2517
+ };
2518
+ let newObject = obj;
2519
+ const oldDomains = Object.keys(domains);
2520
+ for (const oldDomain of oldDomains) {
2521
+ const stringified = JSON.stringify(newObject);
2522
+ try {
2523
+ const replacedString = stringified.replace(new RegExp(oldDomain, 'g'), domains[oldDomain]);
2524
+ newObject = JSON.parse(replacedString);
2525
+ } catch (error) {
2526
+ console.error(error);
2527
+ }
2528
+ }
2529
+ return newObject;
2530
+ }
2513
2531
  static getEnvId(label_api_key) {
2514
2532
  return label_api_key.length === 38 ? parseInt(label_api_key.substring(37, 38), 10) : 2;
2515
2533
  }
@@ -2523,7 +2541,12 @@ class SmarticoAPI {
2523
2541
  return C_SOCKET_PROD.replace('{ENV_ID}', SmarticoAPI.getEnvDnsSuffix(label_api_key));
2524
2542
  }
2525
2543
  static getAvatarUrl(label_api_key) {
2526
- return AVATAR_DOMAIN.replace('{ENV_ID}', SmarticoAPI.getEnvDnsSuffix(label_api_key));
2544
+ const envId = SmarticoAPI.getEnvDnsSuffix(label_api_key);
2545
+ if (envId === '4') {
2546
+ return 'https://dvm0p9vsezqr2.cloudfront.net';
2547
+ } else {
2548
+ return AVATAR_DOMAIN.replace('{ENV_ID}', SmarticoAPI.getEnvDnsSuffix(label_api_key));
2549
+ }
2527
2550
  }
2528
2551
  async send(message, expectCID, force_language) {
2529
2552
  if (this.logCIDs.includes(message.cid)) {
@@ -2537,6 +2560,9 @@ class SmarticoAPI {
2537
2560
  const timeStart = new Date().getTime();
2538
2561
  result = await this.messageSender(message, this.publicUrl, expectCID);
2539
2562
  const timeEnd = new Date().getTime();
2563
+ if (this.label_api_key === 'a6e7ac26-c368-4892-9380-96e7ff82cf3e-4' && result) {
2564
+ result = this.replaceDomains(result);
2565
+ }
2540
2566
  if (this.logHTTPTiming) {
2541
2567
  this.logger.always('HTTP time, ms:' + (timeEnd - timeStart));
2542
2568
  }