@xuda.io/account_module 1.2.1405 → 1.2.1406
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/index.mjs +105 -4
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -2065,7 +2065,7 @@ export const add_contact = async function (req, job_id, headers) {
|
|
|
2065
2065
|
};
|
|
2066
2066
|
|
|
2067
2067
|
const set_account_profile_picture = async function (uid, account_uid) {
|
|
2068
|
-
await
|
|
2068
|
+
await update_account_profile_picture_status(account_uid, 1);
|
|
2069
2069
|
try {
|
|
2070
2070
|
let profile_picture;
|
|
2071
2071
|
|
|
@@ -2075,7 +2075,7 @@ const set_account_profile_picture = async function (uid, account_uid) {
|
|
|
2075
2075
|
if (account_code < 0) {
|
|
2076
2076
|
throw new Error(`account ${account_uid} not found`);
|
|
2077
2077
|
}
|
|
2078
|
-
await
|
|
2078
|
+
await update_account_profile_picture_status(account_uid, 2);
|
|
2079
2079
|
if (!account_info.profile_picture) {
|
|
2080
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);
|
|
2081
2081
|
|
|
@@ -2137,10 +2137,111 @@ const set_account_profile_picture = async function (uid, account_uid) {
|
|
|
2137
2137
|
account_info.profile_avatar = account_info.profile_avatar_obj.file_url;
|
|
2138
2138
|
|
|
2139
2139
|
const account_save_ret = await db_module.save_couch_doc('xuda_accounts', account_obj);
|
|
2140
|
-
await
|
|
2140
|
+
await update_account_profile_picture_status(account_uid, 3);
|
|
2141
2141
|
}
|
|
2142
2142
|
} catch (error) {
|
|
2143
|
-
await
|
|
2143
|
+
await update_account_profile_picture_status(account_uid, 3);
|
|
2144
|
+
}
|
|
2145
|
+
};
|
|
2146
|
+
|
|
2147
|
+
const set_contact_profile_picture = async function (uid, contact_uid) {
|
|
2148
|
+
await update_contact_profile_picture_status(account_uid, 1);
|
|
2149
|
+
try {
|
|
2150
|
+
let profile_picture;
|
|
2151
|
+
|
|
2152
|
+
let { code: account_code, data: account_obj } = await db_module.get_couch_doc('xuda_accounts', account_uid);
|
|
2153
|
+
let account_info = account_obj.account_info;
|
|
2154
|
+
|
|
2155
|
+
if (account_code < 0) {
|
|
2156
|
+
throw new Error(`account ${account_uid} not found`);
|
|
2157
|
+
}
|
|
2158
|
+
await update_contact_profile_picture_status(account_uid, 2);
|
|
2159
|
+
if (!account_info.profile_picture) {
|
|
2160
|
+
const file_ret = await ai_module.get_profile_picture(uid, account_type, name, { email, context, metadata, account_info }, account_profile_info, job_id, headers);
|
|
2161
|
+
|
|
2162
|
+
let { code: account_code, data: account_obj } = await db_module.get_couch_doc('xuda_accounts', account_uid);
|
|
2163
|
+
let account_info = account_obj.account_info;
|
|
2164
|
+
|
|
2165
|
+
account_info.profile_picture_obj = file_ret.data;
|
|
2166
|
+
|
|
2167
|
+
account_info.profile_picture = account_info.profile_picture_obj.file_url;
|
|
2168
|
+
account_info.profile_picture_source = file_ret.profile_picture_source;
|
|
2169
|
+
const account_save_ret = await db_module.save_couch_doc('xuda_accounts', account_obj);
|
|
2170
|
+
profile_picture = account_info.profile_picture;
|
|
2171
|
+
}
|
|
2172
|
+
|
|
2173
|
+
if (!account_info.profile_avatar) {
|
|
2174
|
+
let business_size;
|
|
2175
|
+
|
|
2176
|
+
switch (account_obj.membership_plan) {
|
|
2177
|
+
case 'free': {
|
|
2178
|
+
business_size = 'unknown';
|
|
2179
|
+
break;
|
|
2180
|
+
}
|
|
2181
|
+
|
|
2182
|
+
case 'pro': {
|
|
2183
|
+
business_size = 'small';
|
|
2184
|
+
break;
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2187
|
+
case 'team': {
|
|
2188
|
+
business_size = 'medium';
|
|
2189
|
+
break;
|
|
2190
|
+
}
|
|
2191
|
+
|
|
2192
|
+
case 'agency': {
|
|
2193
|
+
business_size = 'large';
|
|
2194
|
+
break;
|
|
2195
|
+
}
|
|
2196
|
+
case 'enterprise_t1':
|
|
2197
|
+
case 'enterprise_t2':
|
|
2198
|
+
case 'enterprise_t3': {
|
|
2199
|
+
business_size = 'enterprise';
|
|
2200
|
+
break;
|
|
2201
|
+
}
|
|
2202
|
+
|
|
2203
|
+
default:
|
|
2204
|
+
business_size = 'unknown';
|
|
2205
|
+
break;
|
|
2206
|
+
}
|
|
2207
|
+
|
|
2208
|
+
const name = account_info.account_type === 'business' ? account_info.business_name : account_info.full_name;
|
|
2209
|
+
const { bio, country, mainCategory, subCategory } = account_info;
|
|
2210
|
+
|
|
2211
|
+
const file_ret = await ai_module.get_profile_avatar(profile_picture, uid, '', account_profile_info, account_info.account_type, 'account', account_uid, { bio, country, mainCategory, subCategory }, business_size, name, account_info.email, job_id, headers);
|
|
2212
|
+
|
|
2213
|
+
let { code: account_code, data: account_obj } = await db_module.get_couch_doc('xuda_accounts', account_uid);
|
|
2214
|
+
let account_info = account_obj.account_info;
|
|
2215
|
+
|
|
2216
|
+
account_info.profile_avatar_obj = file_ret;
|
|
2217
|
+
account_info.profile_avatar = account_info.profile_avatar_obj.file_url;
|
|
2218
|
+
|
|
2219
|
+
const account_save_ret = await db_module.save_couch_doc('xuda_accounts', account_obj);
|
|
2220
|
+
await update_contact_profile_picture_status(account_uid, 3);
|
|
2221
|
+
}
|
|
2222
|
+
} catch (error) {
|
|
2223
|
+
await update_contact_profile_picture_status(account_uid, 3);
|
|
2224
|
+
}
|
|
2225
|
+
};
|
|
2226
|
+
|
|
2227
|
+
const update_account_profile_picture_status = async function (uid, stat) {
|
|
2228
|
+
try {
|
|
2229
|
+
let doc = await db_module.get_couch_doc_native('xuda_accounts', uid);
|
|
2230
|
+
doc.account_info.profile_avatar_stat = stat;
|
|
2231
|
+
const save_ret = await db_module.save_couch_doc_native('xuda_accounts', doc);
|
|
2232
|
+
} catch (err) {
|
|
2233
|
+
console.error(err);
|
|
2234
|
+
}
|
|
2235
|
+
};
|
|
2236
|
+
|
|
2237
|
+
const update_contact_profile_picture_status = async function (uid, contact_id, stat) {
|
|
2238
|
+
const account_profile_info = await get_active_account_profile_info(uid);
|
|
2239
|
+
try {
|
|
2240
|
+
let doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, contact_id);
|
|
2241
|
+
doc.profile_avatar_stat = stat;
|
|
2242
|
+
const save_ret = await db_module.save_app_couch_doc_native(account_profile_info.app_id, doc);
|
|
2243
|
+
} catch (err) {
|
|
2244
|
+
console.error(err);
|
|
2144
2245
|
}
|
|
2145
2246
|
};
|
|
2146
2247
|
|