@xuda.io/account_module 1.2.1933 → 1.2.1935

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 +32 -8
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -45,7 +45,6 @@ const _utils = await import(path.join(process.env.XUDA_HOME, 'common', 'xuda-cpi
45
45
  // Module Paths
46
46
  const module_path = path.join(process.env.XUDA_HOME, 'cpi') + (!_conf.is_debug ? '/node_modules/@xuda.io' : '');
47
47
  const db_module = await import(`${module_path}/db_module/index.mjs`);
48
- const ai_module = await import(`${module_path}/ai_module/index.mjs`);
49
48
 
50
49
  export const update_account_info = async function (req, job_id, headers) {
51
50
  const marketplace_module = await import(`${module_path}/marketplace_module/index.mjs`);
@@ -195,7 +194,7 @@ export const update_account_info = async function (req, job_id, headers) {
195
194
 
196
195
  const save_ret = await db_module.save_couch_doc('xuda_accounts', account_obj);
197
196
 
198
- // const ai_module = await import(`${module_path}/ai_module/index.mjs`);
197
+ const ai_module = await import(`${module_path}/ai_module/index.mjs`);
199
198
 
200
199
  if (account_obj.account_info?.profile_picture) {
201
200
  if (!account_obj.account_info?.profile_avatar && account_obj.account_info.profile_avatar_stat !== 2) {
@@ -1975,7 +1974,7 @@ export const get_account_ai_usage = async function (req, job_id, headers) {
1975
1974
  };
1976
1975
 
1977
1976
  const set_account_profile_picture = async function (uid, account_uid, metadata, job_id, headers, account_profile_info) {
1978
- // const ai_module = await import(`${module_path}/ai_module/index.mjs`);
1977
+ const ai_module = await import(`${module_path}/ai_module/index.mjs`);
1979
1978
  // const account_profile_info = await get_active_account_profile_info(uid);
1980
1979
  await update_account_profile_picture_status(account_uid, 1);
1981
1980
  try {
@@ -2117,7 +2116,7 @@ export const add_contact = async function (req, job_id, headers) {
2117
2116
  const account_profile_info = await get_active_account_profile_info(uid, profile_id);
2118
2117
  const { account_profile_obj } = account_profile_info;
2119
2118
 
2120
- // const ai_module = await import(`${module_path}/ai_module/index.mjs`);
2119
+ const ai_module = await import(`${module_path}/ai_module/index.mjs`);
2121
2120
 
2122
2121
  //////////////////
2123
2122
  const opt = {
@@ -2241,7 +2240,7 @@ export const add_contact = async function (req, job_id, headers) {
2241
2240
  };
2242
2241
 
2243
2242
  const set_contact_profile_picture = async function (uid, contact_id, metadata, job_id, headers, account_profile_info, create_avatar) {
2244
- // const ai_module = await import(`${module_path}/ai_module/index.mjs`);
2243
+ const ai_module = await import(`${module_path}/ai_module/index.mjs`);
2245
2244
 
2246
2245
  let contact_obj;
2247
2246
  await update_contact_profile_picture_status(uid, contact_id, 1);
@@ -2607,7 +2606,7 @@ export const delete_contact = async function (req, job_id, headers) {
2607
2606
  contact_doc.stat_reason = 'deleted by the user';
2608
2607
 
2609
2608
  const contact_save_ret = await save_contact(uid, contact_doc);
2610
- // const ai_module = await import(`${module_path}/ai_module/index.mjs`);
2609
+ const ai_module = await import(`${module_path}/ai_module/index.mjs`);
2611
2610
  ai_module.delete_depended_chats(uid, contact_id);
2612
2611
  return contact_save_ret;
2613
2612
  } catch (err) {
@@ -2845,6 +2844,31 @@ export const not_spam_contact = async function (req, job_id, headers) {
2845
2844
  }
2846
2845
  };
2847
2846
 
2847
+ export const generate_contact_avatar = async function (req, job_id, headers) {
2848
+ // const email_module = await import(`${module_path}/email_module/index.mjs`);
2849
+ // const ai_module = await import(`${module_path}/ai_module/index.mjs`);
2850
+
2851
+ const { contact_id, uid } = req;
2852
+ const account_profile_info = await get_active_account_profile_info(uid);
2853
+ try {
2854
+ var contact_doc = await get_contact(uid, contact_id);
2855
+ contact_doc.profile_picture_obj = null;
2856
+ contact_doc.profile_picture = null;
2857
+ contact_doc.profile_avatar_obj = null;
2858
+ contact_doc.profile_avatar = null;
2859
+
2860
+ const contact_save_ret = await save_contact(uid, contact_doc);
2861
+ await delete_xuda_cache(contact_doc);
2862
+ set_contact_profile_picture(uid, contact_doc._id, {}, job_id, headers, account_profile_info, true);
2863
+
2864
+ return contact_save_ret;
2865
+ } catch (err) {
2866
+ return {
2867
+ code: -24,
2868
+ data: err.message,
2869
+ };
2870
+ }
2871
+ };
2848
2872
  //////// PROFILES //////////////
2849
2873
 
2850
2874
  export const get_pending_share_profile_in = async function (uid, _id) {
@@ -2871,7 +2895,7 @@ export const get_pending_share_profile_in = async function (uid, _id) {
2871
2895
  };
2872
2896
 
2873
2897
  export const get_account_profile_info = async function (uid, contact_profile_doc, _id) {
2874
- // const ai_module = await import(`${module_path}/ai_module/index.mjs`);
2898
+ const ai_module = await import(`${module_path}/ai_module/index.mjs`);
2875
2899
  const app_id = await get_account_default_project_id(uid);
2876
2900
  let doc = contact_profile_doc;
2877
2901
  if (_id) {
@@ -3176,7 +3200,7 @@ export const delete_account_profile = async function (req, job_id, headers) {
3176
3200
  account_profile_doc.stat_reason = 'deleted by the user';
3177
3201
 
3178
3202
  const account_profile_save_ret = await db_module.save_app_couch_doc(app_id, account_profile_doc);
3179
- // const ai_module = await import(`${module_path}/ai_module/index.mjs`);
3203
+ const ai_module = await import(`${module_path}/ai_module/index.mjs`);
3180
3204
  ai_module.delete_depended_chats(uid, profile_id);
3181
3205
  return account_profile_save_ret;
3182
3206
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/account_module",
3
- "version": "1.2.1933",
3
+ "version": "1.2.1935",
4
4
  "description": "Xuda Account Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {