@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.
Files changed (2) hide show
  1. package/index.mjs +44 -36
  2. 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
- // const ai_module = await import(`${module_path}/ai_module/index.mjs`);
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
- await db_module.save_couch_doc_native('xuda_accounts', {
2898
- _id: await _common.xuda_get_uuid('spam_whitelist'),
2899
- uid,
2900
- docType: 'spam_whitelist',
2901
- email: contact_doc.email,
2902
- date_created_ts: Date.now(),
2903
- stat: 3,
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
- selector: {
2914
- docType: 'email',
2915
- contact_id,
2916
- stat: 3,
2917
- process_stat: 'partial',
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
- const app_id = await get_account_default_project_id(uid);
2923
- if (email.conversation_id) {
2924
- db_module.delete_app_couch_doc(app_id, email.conversation_id);
2925
- email.conversation_id = null;
2926
- }
2927
- if (email.conversation_item_id) {
2928
- db_module.delete_app_couch_doc(app_id, email.conversation_item_id);
2929
- email.conversation_item_id = null;
2930
- }
2931
- const save_ret = await db_module.save_app_couch_doc_native(app_id, email);
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
- // save attachments
2934
- // summarized_body
2935
- req.uid = email.uid;
2936
- req.email_id = email._id;
2937
- await email_module.process_pending_email(req, job_id, headers);
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
- // await process_email(email.email_account_id, profile, uid, email._id, job_id, headers, null, true);
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: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/account_module",
3
- "version": "1.2.1947",
3
+ "version": "1.2.1949",
4
4
  "description": "Xuda Account Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {