@xuda.io/account_module 1.2.1030 → 1.2.1032
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 +19 -19
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -2488,16 +2488,16 @@ setTimeout(async () => {
|
|
|
2488
2488
|
}, 1000);
|
|
2489
2489
|
|
|
2490
2490
|
export const get_profiles = async function (req) {
|
|
2491
|
-
const { _id, uid, name, limit, skip, bookmark, search, filter_type = 'all',
|
|
2491
|
+
const { _id, uid, name, limit, skip, bookmark, search, filter_type = 'all', profile_id } = req;
|
|
2492
2492
|
|
|
2493
2493
|
if (_id) {
|
|
2494
|
-
let data = await db_module.get_couch_doc('
|
|
2494
|
+
let data = await db_module.get_couch_doc('xuda_accounts', _id);
|
|
2495
2495
|
return data;
|
|
2496
2496
|
}
|
|
2497
2497
|
|
|
2498
2498
|
var opt = {
|
|
2499
2499
|
selector: {
|
|
2500
|
-
docType: '
|
|
2500
|
+
docType: 'account_profile',
|
|
2501
2501
|
uid,
|
|
2502
2502
|
stat: { $lt: 4 },
|
|
2503
2503
|
},
|
|
@@ -2529,12 +2529,12 @@ export const get_profiles = async function (req) {
|
|
|
2529
2529
|
opt.selector._id = _id;
|
|
2530
2530
|
}
|
|
2531
2531
|
|
|
2532
|
-
if (
|
|
2533
|
-
opt.selector._id =
|
|
2532
|
+
if (profile_id) {
|
|
2533
|
+
opt.selector._id = profile_id;
|
|
2534
2534
|
}
|
|
2535
2535
|
|
|
2536
|
-
if (typeof
|
|
2537
|
-
opt.selector.name = { $regex: `(?i)${
|
|
2536
|
+
if (typeof profile_name !== 'undefined') {
|
|
2537
|
+
opt.selector.name = { $regex: `(?i)${profile_name}` };
|
|
2538
2538
|
}
|
|
2539
2539
|
|
|
2540
2540
|
if (typeof search !== 'undefined') {
|
|
@@ -2559,8 +2559,8 @@ export const get_profiles = async function (req) {
|
|
|
2559
2559
|
let contacts = { docs: [], total_docs: 0 };
|
|
2560
2560
|
|
|
2561
2561
|
if (filter_type !== 'pending') {
|
|
2562
|
-
contacts = await db_module.find_couch_query('
|
|
2563
|
-
if (!limit ||
|
|
2562
|
+
contacts = await db_module.find_couch_query('xuda_accounts', opt);
|
|
2563
|
+
if (!limit || profile_id) {
|
|
2564
2564
|
contacts.total_docs = contacts.docs.length;
|
|
2565
2565
|
} else {
|
|
2566
2566
|
delete opt.sort;
|
|
@@ -2598,7 +2598,7 @@ export const get_profiles = async function (req) {
|
|
|
2598
2598
|
contact_docs.docs.push(doc);
|
|
2599
2599
|
}
|
|
2600
2600
|
|
|
2601
|
-
if (!
|
|
2601
|
+
if (!profile_id) {
|
|
2602
2602
|
if (filter_type === 'pending') {
|
|
2603
2603
|
////// TO - OUT
|
|
2604
2604
|
requests_to.docs = await get_pending_contact_out(uid);
|
|
@@ -2628,9 +2628,9 @@ export const get_profiles = async function (req) {
|
|
|
2628
2628
|
};
|
|
2629
2629
|
|
|
2630
2630
|
export const archive_profile = async function (req) {
|
|
2631
|
-
const {
|
|
2631
|
+
const { profile_id } = req;
|
|
2632
2632
|
try {
|
|
2633
|
-
var contact_doc = await db_module.get_couch_doc_native('xuda_contacts',
|
|
2633
|
+
var contact_doc = await db_module.get_couch_doc_native('xuda_contacts', profile_id);
|
|
2634
2634
|
contact_doc.stat = 5;
|
|
2635
2635
|
contact_doc.stat_ts = Date.now();
|
|
2636
2636
|
contact_doc.stat_reason = 'archived by the user';
|
|
@@ -2647,9 +2647,9 @@ export const archive_profile = async function (req) {
|
|
|
2647
2647
|
};
|
|
2648
2648
|
|
|
2649
2649
|
export const delete_profile = async function (req, job_id, headers) {
|
|
2650
|
-
const {
|
|
2650
|
+
const { profile_id } = req;
|
|
2651
2651
|
try {
|
|
2652
|
-
var contact_doc = await db_module.get_couch_doc_native('xuda_contacts',
|
|
2652
|
+
var contact_doc = await db_module.get_couch_doc_native('xuda_contacts', profile_id);
|
|
2653
2653
|
|
|
2654
2654
|
contact_doc.stat = 4;
|
|
2655
2655
|
contact_doc.stat_ts = Date.now();
|
|
@@ -2657,7 +2657,7 @@ export const delete_profile = async function (req, job_id, headers) {
|
|
|
2657
2657
|
|
|
2658
2658
|
const contact_save_ret = await db_module.save_couch_doc('xuda_contacts', contact_doc);
|
|
2659
2659
|
|
|
2660
|
-
ai_module.delete_depended_chats(uid,
|
|
2660
|
+
ai_module.delete_depended_chats(uid, profile_id);
|
|
2661
2661
|
return contact_save_ret;
|
|
2662
2662
|
} catch (err) {
|
|
2663
2663
|
return {
|
|
@@ -2668,9 +2668,9 @@ export const delete_profile = async function (req, job_id, headers) {
|
|
|
2668
2668
|
};
|
|
2669
2669
|
|
|
2670
2670
|
export const unarchive_profile = async function (req) {
|
|
2671
|
-
const {
|
|
2671
|
+
const { profile_id } = req;
|
|
2672
2672
|
try {
|
|
2673
|
-
var contact_doc = await db_module.get_couch_doc_native('xuda_contacts',
|
|
2673
|
+
var contact_doc = await db_module.get_couch_doc_native('xuda_contacts', profile_id);
|
|
2674
2674
|
|
|
2675
2675
|
if (contact_doc.stat !== 5) {
|
|
2676
2676
|
throw new Error('contact is not archived');
|
|
@@ -2692,9 +2692,9 @@ export const unarchive_profile = async function (req) {
|
|
|
2692
2692
|
};
|
|
2693
2693
|
|
|
2694
2694
|
export const unfriend_profile = async function (req) {
|
|
2695
|
-
const {
|
|
2695
|
+
const { profile_id } = req;
|
|
2696
2696
|
try {
|
|
2697
|
-
const contact_ret = await db_module.get_couch_doc('xuda_contacts',
|
|
2697
|
+
const contact_ret = await db_module.get_couch_doc('xuda_contacts', profile_id);
|
|
2698
2698
|
if (contact_ret.code < 0) {
|
|
2699
2699
|
throw new Error(contact_ret.data);
|
|
2700
2700
|
}
|