@xuda.io/account_module 1.2.1786 → 1.2.1788
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 +62 -62
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -2070,6 +2070,30 @@ setTimeout(async () => {
|
|
|
2070
2070
|
|
|
2071
2071
|
//////// CONTACTS //////////////
|
|
2072
2072
|
|
|
2073
|
+
function identifyPersonalProvider(domain) {
|
|
2074
|
+
const providers = {
|
|
2075
|
+
'gmail.com': 'Google Gmail',
|
|
2076
|
+
'googlemail.com': 'Google Gmail',
|
|
2077
|
+
'outlook.com': 'Microsoft Outlook',
|
|
2078
|
+
'hotmail.com': 'Microsoft Hotmail',
|
|
2079
|
+
'live.com': 'Microsoft Live',
|
|
2080
|
+
'yahoo.com': 'Yahoo Mail',
|
|
2081
|
+
'ymail.com': 'Yahoo Mail',
|
|
2082
|
+
'aol.com': 'AOL Mail',
|
|
2083
|
+
'icloud.com': 'Apple iCloud',
|
|
2084
|
+
'me.com': 'Apple iCloud',
|
|
2085
|
+
'mac.com': 'Apple iCloud',
|
|
2086
|
+
'protonmail.com': 'ProtonMail',
|
|
2087
|
+
'proton.me': 'ProtonMail',
|
|
2088
|
+
'zoho.com': 'Zoho Mail',
|
|
2089
|
+
'yandex.com': 'Yandex Mail',
|
|
2090
|
+
'mail.com': 'Mail.com',
|
|
2091
|
+
'gmx.com': 'GMX Mail',
|
|
2092
|
+
};
|
|
2093
|
+
|
|
2094
|
+
return providers[domain.toLowerCase()];
|
|
2095
|
+
}
|
|
2096
|
+
|
|
2073
2097
|
export const add_contact = async function (req, job_id, headers) {
|
|
2074
2098
|
try {
|
|
2075
2099
|
const { profile_id, uid, email, name, stat, contact_uid, context, source, team_req_id, metadata = {} } = req;
|
|
@@ -2095,30 +2119,6 @@ export const add_contact = async function (req, job_id, headers) {
|
|
|
2095
2119
|
return { code: -1, data: 'contact already exist', contact_id: user_contacts.docs[0]._id };
|
|
2096
2120
|
}
|
|
2097
2121
|
|
|
2098
|
-
function identifyPersonalProvider(domain) {
|
|
2099
|
-
const providers = {
|
|
2100
|
-
'gmail.com': 'Google Gmail',
|
|
2101
|
-
'googlemail.com': 'Google Gmail',
|
|
2102
|
-
'outlook.com': 'Microsoft Outlook',
|
|
2103
|
-
'hotmail.com': 'Microsoft Hotmail',
|
|
2104
|
-
'live.com': 'Microsoft Live',
|
|
2105
|
-
'yahoo.com': 'Yahoo Mail',
|
|
2106
|
-
'ymail.com': 'Yahoo Mail',
|
|
2107
|
-
'aol.com': 'AOL Mail',
|
|
2108
|
-
'icloud.com': 'Apple iCloud',
|
|
2109
|
-
'me.com': 'Apple iCloud',
|
|
2110
|
-
'mac.com': 'Apple iCloud',
|
|
2111
|
-
'protonmail.com': 'ProtonMail',
|
|
2112
|
-
'proton.me': 'ProtonMail',
|
|
2113
|
-
'zoho.com': 'Zoho Mail',
|
|
2114
|
-
'yandex.com': 'Yandex Mail',
|
|
2115
|
-
'mail.com': 'Mail.com',
|
|
2116
|
-
'gmx.com': 'GMX Mail',
|
|
2117
|
-
};
|
|
2118
|
-
|
|
2119
|
-
return providers[domain.toLowerCase()];
|
|
2120
|
-
}
|
|
2121
|
-
|
|
2122
2122
|
/////////////////
|
|
2123
2123
|
|
|
2124
2124
|
let is_spam = false;
|
|
@@ -2158,7 +2158,7 @@ export const add_contact = async function (req, job_id, headers) {
|
|
|
2158
2158
|
const is_business = await ai_module.is_business_contact(uid, email, name, metadata.subject, metadata.summarized_body, account_profile_info);
|
|
2159
2159
|
account_type = is_business ? 'business' : 'personal';
|
|
2160
2160
|
if (is_business) {
|
|
2161
|
-
business_info = await ai_module.get_business_info(uid, '',
|
|
2161
|
+
business_info = await ai_module.get_business_info(uid, '', email, account_profile_info);
|
|
2162
2162
|
if (business_info.business_name !== 'Not available') {
|
|
2163
2163
|
//&& !identifyPersonalProvider(business_info.business_domain)
|
|
2164
2164
|
business_has_person = await ai_module.is_business_contact_has_person(uid, email, name, metadata.subject, metadata.summarized_body, account_profile_info);
|
|
@@ -2208,48 +2208,48 @@ export const add_contact = async function (req, job_id, headers) {
|
|
|
2208
2208
|
// account_type_info: cached_contact?.account_type_info || account_type_info,
|
|
2209
2209
|
// email_type_info: cached_contact?.email_type_info || email_type_info,
|
|
2210
2210
|
};
|
|
2211
|
-
if (!_.isEmpty(cached_contact?.business_info)) {
|
|
2212
|
-
|
|
2213
|
-
} else {
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2211
|
+
// if (!_.isEmpty(cached_contact?.business_info)) {
|
|
2212
|
+
// contact_obj.business_info = _.cloneDeep(cached_contact.business_info);
|
|
2213
|
+
// } else {
|
|
2214
|
+
if (!is_spam) {
|
|
2215
|
+
// if (account_type === 'business') {
|
|
2216
|
+
// contact_obj.business_info = await ai_module.get_business_info(uid, contact_obj.name, contact_obj.email, account_profile_info);
|
|
2217
|
+
// save_xuda_cache(uid, 'contact', contact_obj.domain, null, contact_obj);
|
|
2218
|
+
|
|
2219
|
+
// // const business_info = await ai_module.get_business_info(uid, contact_obj.name, contact_obj.email, account_profile_info);
|
|
2220
|
+
// // if (business_info) {
|
|
2221
|
+
// // const { business_size, business_category, business_sub_category, business_country, business_bio, business_name } = business_info;
|
|
2222
|
+
// // contact_obj.mainCategory = business_category;
|
|
2223
|
+
// // contact_obj.subCategory = business_sub_category;
|
|
2224
|
+
// // contact_obj.business_size = business_size;
|
|
2225
|
+
// // contact_obj.country = business_country;
|
|
2226
|
+
// // contact_obj.bio = business_bio;
|
|
2227
|
+
// // contact_obj.business_name = business_name;
|
|
2228
|
+
|
|
2229
|
+
// // if (!contact_obj.name) {
|
|
2230
|
+
// // contact_obj.name = business_name;
|
|
2231
|
+
// // }
|
|
2232
|
+
// // }
|
|
2233
|
+
// }
|
|
2234
2234
|
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
if (!contact_obj.name) {
|
|
2238
|
-
contact_obj.name = await ai_module.get_name_from_email_addr(uid, contact_obj.email, account_profile_info);
|
|
2239
|
-
}
|
|
2240
|
-
}
|
|
2241
|
-
} else {
|
|
2235
|
+
if (account_type === 'personal' || contact_obj?.business_has_person) {
|
|
2236
|
+
contact_obj.person_info = await ai_module.get_person_info(uid, contact_obj.name, contact_obj.email, account_profile_info, metadata?.summarized_body);
|
|
2242
2237
|
if (!contact_obj.name) {
|
|
2243
|
-
contact_obj.name =
|
|
2238
|
+
contact_obj.name = await ai_module.get_name_from_email_addr(uid, contact_obj.email, account_profile_info);
|
|
2244
2239
|
}
|
|
2245
2240
|
}
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
// }
|
|
2251
|
-
// }
|
|
2241
|
+
} else {
|
|
2242
|
+
if (!contact_obj.name) {
|
|
2243
|
+
contact_obj.name = '';
|
|
2244
|
+
}
|
|
2252
2245
|
}
|
|
2246
|
+
|
|
2247
|
+
// if (account_type === 'personal') {
|
|
2248
|
+
// if (!contact_obj.name) {
|
|
2249
|
+
// contact_obj.name = await ai_module.get_name_from_email_addr(uid, contact_obj.email, account_profile_info);
|
|
2250
|
+
// }
|
|
2251
|
+
// }
|
|
2252
|
+
// }
|
|
2253
2253
|
// else {
|
|
2254
2254
|
// // get from cache
|
|
2255
2255
|
|