@xuda.io/account_module 1.2.1947 → 1.2.1949
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 +44 -36
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -2885,8 +2885,8 @@ export const generate_contact_avatar = async function (req, job_id, headers) {
|
|
|
2885
2885
|
};
|
|
2886
2886
|
|
|
2887
2887
|
export const deep_research_contact = async function (req, job_id, headers) {
|
|
2888
|
-
const email_module = await import(`${module_path}/email_module/index.mjs`);
|
|
2889
|
-
|
|
2888
|
+
// const email_module = await import(`${module_path}/email_module/index.mjs`);
|
|
2889
|
+
const ai_module = await import(`${module_path}/ai_module/index.mjs`);
|
|
2890
2890
|
|
|
2891
2891
|
const { contact_id, uid } = req;
|
|
2892
2892
|
const account_profile_info = await get_active_account_profile_info(uid);
|
|
@@ -2894,14 +2894,22 @@ export const deep_research_contact = async function (req, job_id, headers) {
|
|
|
2894
2894
|
var contact_doc = await get_contact(uid, contact_id);
|
|
2895
2895
|
contact_doc.is_spam = false;
|
|
2896
2896
|
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2897
|
+
if (contact_doc.account_type === 'business') {
|
|
2898
|
+
contact_doc.business_info = await ai_module.get_business_info(uid, '', contact_doc.email, account_profile_info);
|
|
2899
|
+
if (contact_doc.business_info.business_name !== 'Not available') {
|
|
2900
|
+
contact_doc.business_has_person = await ai_module.is_business_contact_has_person(uid, contact_doc.email, contact_doc.name, contact_doc?.metadata?.subject, contact_doc?.metadata?.summarized_body, account_profile_info);
|
|
2901
|
+
} else {
|
|
2902
|
+
contact_doc.account_type = 'personal';
|
|
2903
|
+
contact_doc.business_info = undefined;
|
|
2904
|
+
}
|
|
2905
|
+
}
|
|
2906
|
+
|
|
2907
|
+
if (contact_doc.account_type === 'personal' || contact_doc?.business_has_person) {
|
|
2908
|
+
contact_doc.person_info = await ai_module.get_person_info(uid, contact_doc.name, contact_doc.email, account_profile_info, contact_doc?.metadata?.summarized_body);
|
|
2909
|
+
if (!contact_doc.name) {
|
|
2910
|
+
contact_doc.name = await ai_module.get_name_from_email_addr(uid, contact_doc.email, account_profile_info);
|
|
2911
|
+
}
|
|
2912
|
+
}
|
|
2905
2913
|
|
|
2906
2914
|
const contact_save_ret = await save_contact(uid, contact_doc);
|
|
2907
2915
|
await delete_xuda_cache(contact_doc);
|
|
@@ -2909,35 +2917,35 @@ export const deep_research_contact = async function (req, job_id, headers) {
|
|
|
2909
2917
|
|
|
2910
2918
|
// find contact emails , set status to 1
|
|
2911
2919
|
|
|
2912
|
-
const emails = await db_module.find_app_couch_query(account_profile_info.app_id, {
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
});
|
|
2920
|
+
// const emails = await db_module.find_app_couch_query(account_profile_info.app_id, {
|
|
2921
|
+
// selector: {
|
|
2922
|
+
// docType: 'email',
|
|
2923
|
+
// contact_id,
|
|
2924
|
+
// stat: 3,
|
|
2925
|
+
// process_stat: 'partial',
|
|
2926
|
+
// },
|
|
2927
|
+
// });
|
|
2920
2928
|
|
|
2921
|
-
for await (let email of emails.docs) {
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2929
|
+
// for await (let email of emails.docs) {
|
|
2930
|
+
// const app_id = await get_account_default_project_id(uid);
|
|
2931
|
+
// if (email.conversation_id) {
|
|
2932
|
+
// db_module.delete_app_couch_doc(app_id, email.conversation_id);
|
|
2933
|
+
// email.conversation_id = null;
|
|
2934
|
+
// }
|
|
2935
|
+
// if (email.conversation_item_id) {
|
|
2936
|
+
// db_module.delete_app_couch_doc(app_id, email.conversation_item_id);
|
|
2937
|
+
// email.conversation_item_id = null;
|
|
2938
|
+
// }
|
|
2939
|
+
// const save_ret = await db_module.save_app_couch_doc_native(app_id, email);
|
|
2932
2940
|
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2941
|
+
// // save attachments
|
|
2942
|
+
// // summarized_body
|
|
2943
|
+
// req.uid = email.uid;
|
|
2944
|
+
// req.email_id = email._id;
|
|
2945
|
+
// await email_module.process_pending_email(req, job_id, headers);
|
|
2938
2946
|
|
|
2939
|
-
|
|
2940
|
-
}
|
|
2947
|
+
// // await process_email(email.email_account_id, profile, uid, email._id, job_id, headers, null, true);
|
|
2948
|
+
// }
|
|
2941
2949
|
|
|
2942
2950
|
// const conversations = await db_module.find_app_couch_query(account_profile_info.app_id, {
|
|
2943
2951
|
// selector: {
|