@xuda.io/account_module 1.2.1061 → 1.2.1063
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 +80 -0
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -2483,6 +2483,86 @@ setTimeout(async () => {
|
|
|
2483
2483
|
console.log(ret);
|
|
2484
2484
|
}, 1000);
|
|
2485
2485
|
|
|
2486
|
+
export const get_account_profile_info = async function (uid, contact_profile_doc, _id) {
|
|
2487
|
+
const ai_module = await import(`${module_path}/ai_module/index.mjs`);
|
|
2488
|
+
let doc = contact_profile_doc;
|
|
2489
|
+
if (_id) {
|
|
2490
|
+
doc = await db_module.get_couch_doc_native('xuda_accounts', _id);
|
|
2491
|
+
}
|
|
2492
|
+
doc.notifications = 0;
|
|
2493
|
+
|
|
2494
|
+
const account_info_ret = await get_account_name({ uid_query: uid });
|
|
2495
|
+
if (account_info_ret.code < 0) {
|
|
2496
|
+
return;
|
|
2497
|
+
}
|
|
2498
|
+
|
|
2499
|
+
doc.profile_avatar = account_info_ret.data.profile_avatar;
|
|
2500
|
+
|
|
2501
|
+
doc.name = account_info_ret.data?.account_type === 'business' ? account_info_ret.data.business_name : `${account_info_ret.data.first_name} ${account_info_ret.data.last_name}`;
|
|
2502
|
+
|
|
2503
|
+
if (account_info_ret.data.phone_number) {
|
|
2504
|
+
try {
|
|
2505
|
+
doc.phone_number = formatPhoneWithFlag(account_info_ret.data.phone_number, account_info_ret.data.country);
|
|
2506
|
+
} catch (err) {
|
|
2507
|
+
console.error(err);
|
|
2508
|
+
doc.phone_number = account_info_ret.data.phone_number;
|
|
2509
|
+
}
|
|
2510
|
+
}
|
|
2511
|
+
|
|
2512
|
+
if (doc.team_req_id) {
|
|
2513
|
+
try {
|
|
2514
|
+
const req_doc = await db_module.get_couch_doc_native('xuda_team', doc.team_req_id);
|
|
2515
|
+
doc.connection_stat = req_doc.team_req_stat;
|
|
2516
|
+
doc.connection_type = req_doc.access_type;
|
|
2517
|
+
if (doc.connection_type === 'contact_connection') {
|
|
2518
|
+
doc.friend_since = req_doc.team_req_date;
|
|
2519
|
+
}
|
|
2520
|
+
} catch (err) {
|
|
2521
|
+
if (err.message === 'deleted') {
|
|
2522
|
+
try {
|
|
2523
|
+
let contact_doc = await db_module.get_couch_doc_native('xuda_contacts', doc._id);
|
|
2524
|
+
contact_doc.team_req_id = '';
|
|
2525
|
+
await db_module.save_couch_doc('xuda_contacts', contact_doc);
|
|
2526
|
+
} catch (error) {}
|
|
2527
|
+
}
|
|
2528
|
+
doc.connection_stat = 0;
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
doc.avatar_source = account_info_ret.data.avatar_source;
|
|
2532
|
+
doc.icon_pattern = await get_contact_pattern(doc);
|
|
2533
|
+
doc.username = account_info_ret.data.username;
|
|
2534
|
+
doc.business_name = account_info_ret.data.business_name;
|
|
2535
|
+
doc.address = account_info_ret.data.address;
|
|
2536
|
+
doc.city = account_info_ret.data.city;
|
|
2537
|
+
doc.state = account_info_ret.data.state;
|
|
2538
|
+
doc.zip = account_info_ret.data.zip;
|
|
2539
|
+
doc.account_type = account_info_ret.data.account_type;
|
|
2540
|
+
doc.email = doc.email?.[0];
|
|
2541
|
+
if (doc.connection_stat === 3) {
|
|
2542
|
+
doc.online = account_info_ret.data.online;
|
|
2543
|
+
}
|
|
2544
|
+
|
|
2545
|
+
doc.interactions = 0;
|
|
2546
|
+
doc.chats = 0;
|
|
2547
|
+
|
|
2548
|
+
const chats_ret = await ai_module.get_ai_chats({ uid, reference_id: doc._id });
|
|
2549
|
+
for (let chat_doc of chats_ret.data.docs) {
|
|
2550
|
+
doc.notifications += chat_doc.notifications;
|
|
2551
|
+
|
|
2552
|
+
doc.chats++;
|
|
2553
|
+
if (chat_doc.interactions) {
|
|
2554
|
+
doc.interactions += chat_doc.interactions;
|
|
2555
|
+
}
|
|
2556
|
+
doc.contact_mood_level = chat_doc.mood_level || 0;
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2559
|
+
doc.card_background = get_contact_background(doc);
|
|
2560
|
+
|
|
2561
|
+
doc.border = get_contact_border(doc);
|
|
2562
|
+
|
|
2563
|
+
return doc;
|
|
2564
|
+
};
|
|
2565
|
+
|
|
2486
2566
|
export const get_account_profiles = async function (req) {
|
|
2487
2567
|
const { _id, uid, profile_name, limit, skip, bookmark, search, filter_type = 'all', profile_id } = req;
|
|
2488
2568
|
|