@xuda.io/account_module 1.2.1936 → 1.2.1938

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 +94 -1
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -2069,7 +2069,7 @@ setTimeout(async () => {
2069
2069
 
2070
2070
  let ret;
2071
2071
 
2072
- ret = await generate_contact_avatar({ uid, contact_id: 'cnt_c07049718613a11d164e90450d5f2742' });
2072
+ // ret = await generate_contact_avatar({ uid, contact_id: 'cnt_c07049718613a11d164e90450d5f2742' });
2073
2073
  // ret = await not_spam_contact({ uid, contact_id: 'cnt_c07049718613a11d164e90450d5f2742' });
2074
2074
  // ret = await get_account_ai_usage({ uid });
2075
2075
  // ret = await create_account_profile({ uid });
@@ -2870,6 +2870,99 @@ export const generate_contact_avatar = async function (req, job_id, headers) {
2870
2870
  };
2871
2871
  }
2872
2872
  };
2873
+
2874
+ export const deep_research_contact = async function (req, job_id, headers) {
2875
+ const email_module = await import(`${module_path}/email_module/index.mjs`);
2876
+ // const ai_module = await import(`${module_path}/ai_module/index.mjs`);
2877
+
2878
+ const { contact_id, uid } = req;
2879
+ const account_profile_info = await get_active_account_profile_info(uid);
2880
+ try {
2881
+ var contact_doc = await get_contact(uid, contact_id);
2882
+ contact_doc.is_spam = false;
2883
+
2884
+ await db_module.save_couch_doc_native('xuda_accounts', {
2885
+ _id: await _common.xuda_get_uuid('spam_whitelist'),
2886
+ uid,
2887
+ docType: 'spam_whitelist',
2888
+ email: contact_doc.email,
2889
+ date_created_ts: Date.now(),
2890
+ stat: 3,
2891
+ });
2892
+
2893
+ const contact_save_ret = await save_contact(uid, contact_doc);
2894
+ await delete_xuda_cache(contact_doc);
2895
+ set_contact_profile_picture(uid, contact_doc._id, {}, job_id, headers, account_profile_info, false);
2896
+
2897
+ // find contact emails , set status to 1
2898
+
2899
+ const emails = await db_module.find_app_couch_query(account_profile_info.app_id, {
2900
+ selector: {
2901
+ docType: 'email',
2902
+ contact_id,
2903
+ stat: 3,
2904
+ process_stat: 'partial',
2905
+ },
2906
+ });
2907
+
2908
+ for await (let email of emails.docs) {
2909
+ const app_id = await get_account_default_project_id(uid);
2910
+ if (email.conversation_id) {
2911
+ db_module.delete_app_couch_doc(app_id, email.conversation_id);
2912
+ email.conversation_id = null;
2913
+ }
2914
+ if (email.conversation_item_id) {
2915
+ db_module.delete_app_couch_doc(app_id, email.conversation_item_id);
2916
+ email.conversation_item_id = null;
2917
+ }
2918
+ const save_ret = await db_module.save_app_couch_doc_native(app_id, email);
2919
+
2920
+ // save attachments
2921
+ // summarized_body
2922
+ req.uid = email.uid;
2923
+ req.email_id = email._id;
2924
+ await email_module.process_pending_email(req, job_id, headers);
2925
+
2926
+ // await process_email(email.email_account_id, profile, uid, email._id, job_id, headers, null, true);
2927
+ }
2928
+
2929
+ // const conversations = await db_module.find_app_couch_query(account_profile_info.app_id, {
2930
+ // selector: {
2931
+ // docType: 'chat_conversation',
2932
+ // reference_id: contact_id,
2933
+ // stat: 3,
2934
+
2935
+ // process_stat: 'partial',
2936
+ // },
2937
+ // });
2938
+
2939
+ // for await (let conversation of conversations.docs) {
2940
+ // await ai_module.process_conversation(uid, conversation._id, account_profile_info, job_id, headers);
2941
+ // await ai_module.update_conversation_mood_level(uid, [{ uid: account_profile_info.uid, contact_id }], conversation._id, conversation.prompt, null, reference_id, conversation.reference_type === 'contacts', account_profile_info);
2942
+
2943
+ // const conversation_items = await db_module.find_app_couch_query(account_profile_info.app_id, {
2944
+ // selector: {
2945
+ // docType: 'chat_conversation_item',
2946
+ // conversation_id: conversation._id,
2947
+ // stat: 3,
2948
+ // process_stat: 'partial',
2949
+ // },
2950
+ // });
2951
+ // for await (let conversation_item of conversation_items.docs) {
2952
+ // }
2953
+ // }
2954
+
2955
+ // update_conversation_mood_level
2956
+ // attachment_handler
2957
+
2958
+ return contact_save_ret;
2959
+ } catch (err) {
2960
+ return {
2961
+ code: -24,
2962
+ data: err.message,
2963
+ };
2964
+ }
2965
+ };
2873
2966
  //////// PROFILES //////////////
2874
2967
 
2875
2968
  export const get_pending_share_profile_in = async function (uid, _id) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/account_module",
3
- "version": "1.2.1936",
3
+ "version": "1.2.1938",
4
4
  "description": "Xuda Account Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {