@xuda.io/account_module 1.2.1059 → 1.2.1060
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 +28 -28
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -2593,14 +2593,14 @@ export const get_account_profiles = async function (req) {
|
|
|
2593
2593
|
export const archive_account_profile = async function (req) {
|
|
2594
2594
|
const { profile_id } = req;
|
|
2595
2595
|
try {
|
|
2596
|
-
var
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2596
|
+
var account_profile_doc = await db_module.get_couch_doc_native('xuda_accounts', profile_id);
|
|
2597
|
+
account_profile_doc.stat = 5;
|
|
2598
|
+
account_profile_doc.stat_ts = Date.now();
|
|
2599
|
+
account_profile_doc.stat_reason = 'archived by the user';
|
|
2600
2600
|
|
|
2601
|
-
const
|
|
2601
|
+
const account_profile_save_ret = await db_module.save_couch_doc('xuda_accounts', account_profile_doc);
|
|
2602
2602
|
|
|
2603
|
-
return
|
|
2603
|
+
return account_profile_save_ret;
|
|
2604
2604
|
} catch (err) {
|
|
2605
2605
|
return {
|
|
2606
2606
|
code: -22,
|
|
@@ -2609,19 +2609,19 @@ export const archive_account_profile = async function (req) {
|
|
|
2609
2609
|
}
|
|
2610
2610
|
};
|
|
2611
2611
|
|
|
2612
|
-
export const
|
|
2612
|
+
export const delete_account_profile = async function (req, job_id, headers) {
|
|
2613
2613
|
const { profile_id } = req;
|
|
2614
2614
|
try {
|
|
2615
|
-
var
|
|
2615
|
+
var account_profile_doc = await db_module.get_couch_doc_native('xuda_accounts', profile_id);
|
|
2616
2616
|
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2617
|
+
account_profile_doc.stat = 4;
|
|
2618
|
+
account_profile_doc.stat_ts = Date.now();
|
|
2619
|
+
account_profile_doc.stat_reason = 'deleted by the user';
|
|
2620
2620
|
|
|
2621
|
-
const
|
|
2621
|
+
const account_profile_save_ret = await db_module.save_couch_doc('xuda_accounts', account_profile_doc);
|
|
2622
2622
|
|
|
2623
2623
|
ai_module.delete_depended_chats(uid, profile_id);
|
|
2624
|
-
return
|
|
2624
|
+
return account_profile_save_ret;
|
|
2625
2625
|
} catch (err) {
|
|
2626
2626
|
return {
|
|
2627
2627
|
code: -22,
|
|
@@ -2630,22 +2630,22 @@ export const delete_profile = async function (req, job_id, headers) {
|
|
|
2630
2630
|
}
|
|
2631
2631
|
};
|
|
2632
2632
|
|
|
2633
|
-
export const
|
|
2633
|
+
export const unarchive_account_profile = async function (req) {
|
|
2634
2634
|
const { profile_id } = req;
|
|
2635
2635
|
try {
|
|
2636
|
-
var
|
|
2636
|
+
var account_profile_doc = await db_module.get_couch_doc_native('xuda_accounts', profile_id);
|
|
2637
2637
|
|
|
2638
|
-
if (
|
|
2638
|
+
if (account_profile_doc.stat !== 5) {
|
|
2639
2639
|
throw new Error('contact is not archived');
|
|
2640
2640
|
}
|
|
2641
2641
|
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2642
|
+
account_profile_doc.stat = 3;
|
|
2643
|
+
account_profile_doc.stat_ts = Date.now();
|
|
2644
|
+
account_profile_doc.stat_reason = 'archived by the user';
|
|
2645
2645
|
|
|
2646
|
-
const
|
|
2646
|
+
const account_profile_save_ret = await db_module.save_couch_doc('xuda_accounts', account_profile_doc);
|
|
2647
2647
|
|
|
2648
|
-
return
|
|
2648
|
+
return account_profile_save_ret;
|
|
2649
2649
|
} catch (err) {
|
|
2650
2650
|
return {
|
|
2651
2651
|
code: -22,
|
|
@@ -2654,25 +2654,25 @@ export const unarchive_profile = async function (req) {
|
|
|
2654
2654
|
}
|
|
2655
2655
|
};
|
|
2656
2656
|
|
|
2657
|
-
export const
|
|
2657
|
+
export const unfriend_account_profile = async function (req) {
|
|
2658
2658
|
const { profile_id } = req;
|
|
2659
2659
|
try {
|
|
2660
2660
|
const contact_ret = await db_module.get_couch_doc('xuda_accounts', profile_id);
|
|
2661
2661
|
if (contact_ret.code < 0) {
|
|
2662
2662
|
throw new Error(contact_ret.data);
|
|
2663
2663
|
}
|
|
2664
|
-
var
|
|
2664
|
+
var account_profile_doc = contact_ret.data;
|
|
2665
2665
|
|
|
2666
|
-
if (!
|
|
2666
|
+
if (!account_profile_doc.team_req_id) {
|
|
2667
2667
|
throw new Error('no friend relationship found');
|
|
2668
2668
|
}
|
|
2669
|
-
let req_doc = await db_module.get_couch_doc_native('xuda_team',
|
|
2669
|
+
let req_doc = await db_module.get_couch_doc_native('xuda_team', account_profile_doc.team_req_id);
|
|
2670
2670
|
req_doc.team_req_stat = 4;
|
|
2671
2671
|
req_doc.team_req_stat_desc = 'unfriend by the user';
|
|
2672
|
-
await db_module.get_couch_doc_native('xuda_team',
|
|
2672
|
+
await db_module.get_couch_doc_native('xuda_team', account_profile_doc.team_req_id);
|
|
2673
2673
|
|
|
2674
|
-
|
|
2675
|
-
const
|
|
2674
|
+
account_profile_doc.team_req_id = null;
|
|
2675
|
+
const account_profile_save_ret = await db_module.save_couch_doc('xuda_accounts', account_profile_doc);
|
|
2676
2676
|
|
|
2677
2677
|
const req_save_ret = await db_module.save_couch_doc('xuda_team', req_doc);
|
|
2678
2678
|
|