@xuda.io/account_module 1.2.1398 → 1.2.1400

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 +58 -52
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -2066,74 +2066,80 @@ export const add_contact = async function (req, job_id, headers) {
2066
2066
  };
2067
2067
 
2068
2068
  const set_account_profile_picture = async function (uid, contact_uid) {
2069
- let profile_picture;
2070
-
2071
- let { code: account_code, data: account_obj } = await db_module.get_couch_doc('xuda_accounts', contact_uid);
2072
- let account_info = account_obj.account_info;
2073
-
2074
- if (account_code < 0) {
2075
- throw new Error(`account ${contact_uid} not found`);
2076
- }
2077
- if (!account_info.profile_picture) {
2078
- const file_ret = await ai_module.get_profile_picture(uid, account_type, name, { email, context, metadata, account_info }, account_profile_info, job_id, headers);
2069
+ try {
2070
+ let profile_picture;
2079
2071
 
2080
2072
  let { code: account_code, data: account_obj } = await db_module.get_couch_doc('xuda_accounts', contact_uid);
2081
2073
  let account_info = account_obj.account_info;
2082
2074
 
2083
- account_info.profile_picture_obj = file_ret.data;
2075
+ if (account_code < 0) {
2076
+ throw new Error(`account ${contact_uid} not found`);
2077
+ }
2078
+ await update_profile_avatar_status(contact_uid, 2);
2079
+ if (!account_info.profile_picture) {
2080
+ const file_ret = await ai_module.get_profile_picture(uid, account_type, name, { email, context, metadata, account_info }, account_profile_info, job_id, headers);
2084
2081
 
2085
- account_info.profile_picture = account_info.profile_picture_obj.file_url;
2086
- account_info.profile_picture_source = file_ret.profile_picture_source;
2087
- const account_save_ret = await db_module.save_couch_doc('xuda_accounts', account_obj);
2088
- profile_picture = account_info.profile_picture;
2089
- }
2082
+ let { code: account_code, data: account_obj } = await db_module.get_couch_doc('xuda_accounts', contact_uid);
2083
+ let account_info = account_obj.account_info;
2090
2084
 
2091
- if (!account_info.profile_avatar) {
2092
- let business_size;
2085
+ account_info.profile_picture_obj = file_ret.data;
2093
2086
 
2094
- switch (account_obj.membership_plan) {
2095
- case 'free': {
2096
- business_size = 'unknown';
2097
- break;
2098
- }
2087
+ account_info.profile_picture = account_info.profile_picture_obj.file_url;
2088
+ account_info.profile_picture_source = file_ret.profile_picture_source;
2089
+ const account_save_ret = await db_module.save_couch_doc('xuda_accounts', account_obj);
2090
+ profile_picture = account_info.profile_picture;
2091
+ }
2099
2092
 
2100
- case 'pro': {
2101
- business_size = 'small';
2102
- break;
2103
- }
2093
+ if (!account_info.profile_avatar) {
2094
+ let business_size;
2104
2095
 
2105
- case 'team': {
2106
- business_size = 'medium';
2107
- break;
2108
- }
2096
+ switch (account_obj.membership_plan) {
2097
+ case 'free': {
2098
+ business_size = 'unknown';
2099
+ break;
2100
+ }
2109
2101
 
2110
- case 'agency': {
2111
- business_size = 'large';
2112
- break;
2113
- }
2114
- case 'enterprise_t1':
2115
- case 'enterprise_t2':
2116
- case 'enterprise_t3': {
2117
- business_size = 'enterprise';
2118
- break;
2119
- }
2102
+ case 'pro': {
2103
+ business_size = 'small';
2104
+ break;
2105
+ }
2120
2106
 
2121
- default:
2122
- business_size = 'unknown';
2123
- break;
2124
- }
2107
+ case 'team': {
2108
+ business_size = 'medium';
2109
+ break;
2110
+ }
2111
+
2112
+ case 'agency': {
2113
+ business_size = 'large';
2114
+ break;
2115
+ }
2116
+ case 'enterprise_t1':
2117
+ case 'enterprise_t2':
2118
+ case 'enterprise_t3': {
2119
+ business_size = 'enterprise';
2120
+ break;
2121
+ }
2122
+
2123
+ default:
2124
+ business_size = 'unknown';
2125
+ break;
2126
+ }
2125
2127
 
2126
- const name = account_info.account_type === 'business' ? account_info.business_name : account_info.full_name;
2128
+ const name = account_info.account_type === 'business' ? account_info.business_name : account_info.full_name;
2127
2129
 
2128
- const file_ret = await ai_module.get_profile_avatar(profile_picture, uid, '', account_profile_info, account_info.account_type, 'account', contact_uid, {}, business_size, name, account_info.email, job_id, headers);
2130
+ const file_ret = await ai_module.get_profile_avatar(profile_picture, uid, '', account_profile_info, account_info.account_type, 'account', contact_uid, {}, business_size, name, account_info.email, job_id, headers);
2129
2131
 
2130
- let { code: account_code, data: account_obj } = await db_module.get_couch_doc('xuda_accounts', contact_uid);
2131
- let account_info = account_obj.account_info;
2132
+ let { code: account_code, data: account_obj } = await db_module.get_couch_doc('xuda_accounts', contact_uid);
2133
+ let account_info = account_obj.account_info;
2132
2134
 
2133
- account_info.profile_avatar_obj = file_ret;
2134
- account_info.profile_avatar = account_info.profile_avatar_obj.file_url;
2135
+ account_info.profile_avatar_obj = file_ret;
2136
+ account_info.profile_avatar = account_info.profile_avatar_obj.file_url;
2135
2137
 
2136
- const account_save_ret = await db_module.save_couch_doc('xuda_accounts', account_obj);
2138
+ const account_save_ret = await db_module.save_couch_doc('xuda_accounts', account_obj);
2139
+ await update_profile_avatar_status(contact_uid, 3);
2140
+ }
2141
+ } catch (error) {
2142
+ await update_profile_avatar_status(contact_uid, 1);
2137
2143
  }
2138
2144
  };
2139
2145
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/account_module",
3
- "version": "1.2.1398",
3
+ "version": "1.2.1400",
4
4
  "description": "Xuda Account Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {