@xuda.io/account_module 1.2.1055 → 1.2.1057
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 +22 -22
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -2593,12 +2593,12 @@ 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 contact_profile_doc = await db_module.get_couch_doc_native('xuda_accounts', profile_id);
|
|
2597
|
+
contact_profile_doc.stat = 5;
|
|
2598
|
+
contact_profile_doc.stat_ts = Date.now();
|
|
2599
|
+
contact_profile_doc.stat_reason = 'archived by the user';
|
|
2600
2600
|
|
|
2601
|
-
const contact_save_ret = await db_module.save_couch_doc('xuda_accounts',
|
|
2601
|
+
const contact_save_ret = await db_module.save_couch_doc('xuda_accounts', contact_profile_doc);
|
|
2602
2602
|
|
|
2603
2603
|
return contact_save_ret;
|
|
2604
2604
|
} catch (err) {
|
|
@@ -2612,13 +2612,13 @@ export const archive_account_profile = async function (req) {
|
|
|
2612
2612
|
export const delete_profile = async function (req, job_id, headers) {
|
|
2613
2613
|
const { profile_id } = req;
|
|
2614
2614
|
try {
|
|
2615
|
-
var
|
|
2615
|
+
var contact_profile_doc = await db_module.get_couch_doc_native('xuda_contacts', profile_id);
|
|
2616
2616
|
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2617
|
+
contact_profile_doc.stat = 4;
|
|
2618
|
+
contact_profile_doc.stat_ts = Date.now();
|
|
2619
|
+
contact_profile_doc.stat_reason = 'deleted by the user';
|
|
2620
2620
|
|
|
2621
|
-
const contact_save_ret = await db_module.save_couch_doc('xuda_contacts',
|
|
2621
|
+
const contact_save_ret = await db_module.save_couch_doc('xuda_contacts', contact_profile_doc);
|
|
2622
2622
|
|
|
2623
2623
|
ai_module.delete_depended_chats(uid, profile_id);
|
|
2624
2624
|
return contact_save_ret;
|
|
@@ -2633,17 +2633,17 @@ export const delete_profile = async function (req, job_id, headers) {
|
|
|
2633
2633
|
export const unarchive_profile = async function (req) {
|
|
2634
2634
|
const { profile_id } = req;
|
|
2635
2635
|
try {
|
|
2636
|
-
var
|
|
2636
|
+
var contact_profile_doc = await db_module.get_couch_doc_native('xuda_contacts', profile_id);
|
|
2637
2637
|
|
|
2638
|
-
if (
|
|
2638
|
+
if (contact_profile_doc.stat !== 5) {
|
|
2639
2639
|
throw new Error('contact is not archived');
|
|
2640
2640
|
}
|
|
2641
2641
|
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2642
|
+
contact_profile_doc.stat = 3;
|
|
2643
|
+
contact_profile_doc.stat_ts = Date.now();
|
|
2644
|
+
contact_profile_doc.stat_reason = 'archived by the user';
|
|
2645
2645
|
|
|
2646
|
-
const contact_save_ret = await db_module.save_couch_doc('xuda_contacts',
|
|
2646
|
+
const contact_save_ret = await db_module.save_couch_doc('xuda_contacts', contact_profile_doc);
|
|
2647
2647
|
|
|
2648
2648
|
return contact_save_ret;
|
|
2649
2649
|
} catch (err) {
|
|
@@ -2661,18 +2661,18 @@ export const unfriend_profile = async function (req) {
|
|
|
2661
2661
|
if (contact_ret.code < 0) {
|
|
2662
2662
|
throw new Error(contact_ret.data);
|
|
2663
2663
|
}
|
|
2664
|
-
var
|
|
2664
|
+
var contact_profile_doc = contact_ret.data;
|
|
2665
2665
|
|
|
2666
|
-
if (!
|
|
2666
|
+
if (!contact_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', contact_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', contact_profile_doc.team_req_id);
|
|
2673
2673
|
|
|
2674
|
-
|
|
2675
|
-
const contact_save_ret = await db_module.save_couch_doc('xuda_contacts',
|
|
2674
|
+
contact_profile_doc.team_req_id = null;
|
|
2675
|
+
const contact_save_ret = await db_module.save_couch_doc('xuda_contacts', contact_profile_doc);
|
|
2676
2676
|
|
|
2677
2677
|
const req_save_ret = await db_module.save_couch_doc('xuda_team', req_doc);
|
|
2678
2678
|
|