@xuda.io/account_module 1.2.1811 → 1.2.1813

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 (2) hide show
  1. package/index.mjs +13 -6
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -2316,10 +2316,17 @@ const set_contact_profile_picture = async function (uid, contact_id, metadata, j
2316
2316
  }
2317
2317
  }
2318
2318
  let file_ret = { code: 1, data: cache };
2319
- debugger;
2319
+
2320
2320
  if (!cache) {
2321
2321
  // if personal, return profile pic, if business return logo
2322
2322
  file_ret = await ai_module.get_profile_picture(uid, contact_obj.account_type, contact_obj?.business_info?.business_domain || contact_obj.name, { email: contact_obj.email, metadata: contact_obj }, account_profile_info, job_id, headers);
2323
+
2324
+ if (file_ret.code < 0) {
2325
+ throw new Error(file_ret.data);
2326
+ }
2327
+
2328
+ if (!_.isObject(file_ret.data)) throw new Error('file_ret not an object');
2329
+
2323
2330
  if (contact_obj?.business_info?.business_domain) {
2324
2331
  if (!identifyPersonalProvider(contact_obj.business_info.business_domain)) {
2325
2332
  save_xuda_cache(uid, 'profile_picture', contact_obj.business_info.business_domain, file_ret.data, { account_type: contact_obj.account_type, type: 'contact' });
@@ -2329,11 +2336,6 @@ const set_contact_profile_picture = async function (uid, contact_id, metadata, j
2329
2336
  }
2330
2337
  save_xuda_cache(uid, 'profile_picture', contact_obj.email, file_ret.data, { account_type: contact_obj.account_type, type: 'contact' });
2331
2338
  }
2332
- if (file_ret.code < 0) {
2333
- throw new Error(file_ret.data);
2334
- }
2335
-
2336
- if (!_.isObject(file_ret.data)) throw new Error('file_ret not an object');
2337
2339
 
2338
2340
  let { code: contact_code, data: contact_obj2 } = await db_module.get_app_couch_doc(account_profile_info.app_id, contact_id);
2339
2341
  contact_obj = contact_obj2;
@@ -2392,6 +2394,11 @@ const set_contact_profile_picture = async function (uid, contact_id, metadata, j
2392
2394
  );
2393
2395
 
2394
2396
  if (file_ret.code < 0) {
2397
+ if (file_ret.data === 'Input file contains unsupported image format') {
2398
+ delete contact_obj.profile_picture;
2399
+ delete contact_obj.profile_picture_obj;
2400
+ await db_module.save_app_couch_doc(account_profile_info.app_id, contact_obj);
2401
+ }
2395
2402
  throw new Error(file_ret.data);
2396
2403
  }
2397
2404
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/account_module",
3
- "version": "1.2.1811",
3
+ "version": "1.2.1813",
4
4
  "description": "Xuda Account Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {