@xuda.io/account_module 1.2.1329 → 1.2.1331
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 +48 -4
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -580,13 +580,11 @@ export const get_account_info = async function (req) {
|
|
|
580
580
|
});
|
|
581
581
|
};
|
|
582
582
|
|
|
583
|
-
export const get_active_account_profile_info = async function (uid) {
|
|
583
|
+
export const get_active_account_profile_info = async function (uid, profile_id) {
|
|
584
584
|
const acc_obj = await db_module.get_couch_doc_native('xuda_accounts', uid);
|
|
585
585
|
|
|
586
|
-
let active_account_profile_id = acc_obj.account_info.active_account_profile_id;
|
|
586
|
+
let active_account_profile_id = profile_id || acc_obj.account_info.active_account_profile_id;
|
|
587
587
|
|
|
588
|
-
try {
|
|
589
|
-
} catch (error) {}
|
|
590
588
|
const account_profile_obj = await db_module.get_app_couch_doc_native(acc_obj.account_project_id, active_account_profile_id);
|
|
591
589
|
if (account_profile_obj.share_item_id) {
|
|
592
590
|
// set the original profile id if shared
|
|
@@ -2777,6 +2775,52 @@ export const update_account_profile = async function (req, job_id, headers) {
|
|
|
2777
2775
|
}
|
|
2778
2776
|
};
|
|
2779
2777
|
|
|
2778
|
+
export const update_entity_account_profiles = async function (req, job_id, headers) {
|
|
2779
|
+
const { uid, entity } = req;
|
|
2780
|
+
const app_id = await get_account_default_project_id(uid);
|
|
2781
|
+
|
|
2782
|
+
try {
|
|
2783
|
+
switch (entity) {
|
|
2784
|
+
case 'ai_chat': {
|
|
2785
|
+
break;
|
|
2786
|
+
}
|
|
2787
|
+
|
|
2788
|
+
default:
|
|
2789
|
+
break;
|
|
2790
|
+
}
|
|
2791
|
+
|
|
2792
|
+
let { data: account_profile_doc } = await db_module.get_app_couch_doc(app_id, _id);
|
|
2793
|
+
|
|
2794
|
+
if (account_profile_doc.docType !== 'account_profile') {
|
|
2795
|
+
throw new Error('not account profile doc');
|
|
2796
|
+
}
|
|
2797
|
+
|
|
2798
|
+
let changes_arr = [];
|
|
2799
|
+
|
|
2800
|
+
for (const key of account_profile_properties) {
|
|
2801
|
+
let val = req[key];
|
|
2802
|
+
if (typeof val === 'undefined') continue;
|
|
2803
|
+
if (account_profile_doc[key] !== val) {
|
|
2804
|
+
changes_arr.push(key);
|
|
2805
|
+
account_profile_doc[key] = val;
|
|
2806
|
+
}
|
|
2807
|
+
}
|
|
2808
|
+
|
|
2809
|
+
if (!changes_arr.length) {
|
|
2810
|
+
// throw new Error('no change');
|
|
2811
|
+
return { code: 56, data: 'no change' };
|
|
2812
|
+
}
|
|
2813
|
+
|
|
2814
|
+
account_profile_doc.ts = Date.now();
|
|
2815
|
+
|
|
2816
|
+
const save_ret = await db_module.save_app_couch_doc(app_id, account_profile_doc);
|
|
2817
|
+
|
|
2818
|
+
return { code: 56, data: save_ret };
|
|
2819
|
+
} catch (err) {
|
|
2820
|
+
return { code: -56, data: err.message };
|
|
2821
|
+
}
|
|
2822
|
+
};
|
|
2823
|
+
|
|
2780
2824
|
export const get_contact = async function (uid, contact_id) {
|
|
2781
2825
|
const account_profile_info = await get_active_account_profile_info(uid);
|
|
2782
2826
|
const contact_ret = await db_module.get_app_couch_doc_native(account_profile_info.app_id, contact_id);
|