@xuda.io/account_module 1.2.1398 → 1.2.1399
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 +55 -53
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -2066,75 +2066,77 @@ 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
|
-
|
|
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
|
-
|
|
2075
|
+
if (account_code < 0) {
|
|
2076
|
+
throw new Error(`account ${contact_uid} not found`);
|
|
2077
|
+
}
|
|
2078
|
+
if (!account_info.profile_picture) {
|
|
2079
|
+
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
2080
|
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
const account_save_ret = await db_module.save_couch_doc('xuda_accounts', account_obj);
|
|
2088
|
-
profile_picture = account_info.profile_picture;
|
|
2089
|
-
}
|
|
2081
|
+
let { code: account_code, data: account_obj } = await db_module.get_couch_doc('xuda_accounts', contact_uid);
|
|
2082
|
+
let account_info = account_obj.account_info;
|
|
2090
2083
|
|
|
2091
|
-
|
|
2092
|
-
let business_size;
|
|
2084
|
+
account_info.profile_picture_obj = file_ret.data;
|
|
2093
2085
|
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2086
|
+
account_info.profile_picture = account_info.profile_picture_obj.file_url;
|
|
2087
|
+
account_info.profile_picture_source = file_ret.profile_picture_source;
|
|
2088
|
+
const account_save_ret = await db_module.save_couch_doc('xuda_accounts', account_obj);
|
|
2089
|
+
profile_picture = account_info.profile_picture;
|
|
2090
|
+
}
|
|
2099
2091
|
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
break;
|
|
2103
|
-
}
|
|
2092
|
+
if (!account_info.profile_avatar) {
|
|
2093
|
+
let business_size;
|
|
2104
2094
|
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2095
|
+
switch (account_obj.membership_plan) {
|
|
2096
|
+
case 'free': {
|
|
2097
|
+
business_size = 'unknown';
|
|
2098
|
+
break;
|
|
2099
|
+
}
|
|
2109
2100
|
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
case 'enterprise_t1':
|
|
2115
|
-
case 'enterprise_t2':
|
|
2116
|
-
case 'enterprise_t3': {
|
|
2117
|
-
business_size = 'enterprise';
|
|
2118
|
-
break;
|
|
2119
|
-
}
|
|
2101
|
+
case 'pro': {
|
|
2102
|
+
business_size = 'small';
|
|
2103
|
+
break;
|
|
2104
|
+
}
|
|
2120
2105
|
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2106
|
+
case 'team': {
|
|
2107
|
+
business_size = 'medium';
|
|
2108
|
+
break;
|
|
2109
|
+
}
|
|
2125
2110
|
|
|
2126
|
-
|
|
2111
|
+
case 'agency': {
|
|
2112
|
+
business_size = 'large';
|
|
2113
|
+
break;
|
|
2114
|
+
}
|
|
2115
|
+
case 'enterprise_t1':
|
|
2116
|
+
case 'enterprise_t2':
|
|
2117
|
+
case 'enterprise_t3': {
|
|
2118
|
+
business_size = 'enterprise';
|
|
2119
|
+
break;
|
|
2120
|
+
}
|
|
2127
2121
|
|
|
2128
|
-
|
|
2122
|
+
default:
|
|
2123
|
+
business_size = 'unknown';
|
|
2124
|
+
break;
|
|
2125
|
+
}
|
|
2129
2126
|
|
|
2130
|
-
|
|
2131
|
-
let account_info = account_obj.account_info;
|
|
2127
|
+
const name = account_info.account_type === 'business' ? account_info.business_name : account_info.full_name;
|
|
2132
2128
|
|
|
2133
|
-
|
|
2134
|
-
account_info.profile_avatar = account_info.profile_avatar_obj.file_url;
|
|
2129
|
+
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);
|
|
2135
2130
|
|
|
2136
|
-
|
|
2137
|
-
|
|
2131
|
+
let { code: account_code, data: account_obj } = await db_module.get_couch_doc('xuda_accounts', contact_uid);
|
|
2132
|
+
let account_info = account_obj.account_info;
|
|
2133
|
+
|
|
2134
|
+
account_info.profile_avatar_obj = file_ret;
|
|
2135
|
+
account_info.profile_avatar = account_info.profile_avatar_obj.file_url;
|
|
2136
|
+
|
|
2137
|
+
const account_save_ret = await db_module.save_couch_doc('xuda_accounts', account_obj);
|
|
2138
|
+
}
|
|
2139
|
+
} catch (error) {}
|
|
2138
2140
|
};
|
|
2139
2141
|
|
|
2140
2142
|
export const get_contacts = async function (req) {
|