@xuda.io/account_module 1.2.1061 → 1.2.1062

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.
Files changed (2) hide show
  1. package/index.mjs +82 -0
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -2483,6 +2483,88 @@ 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
+ //membership_plan
2502
+ // doc.name = `${account_info_ret.data.first_name} ${account_info_ret.data.last_name}`;
2503
+ 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}`;
2504
+
2505
+ if (account_info_ret.data.phone_number) {
2506
+ try {
2507
+ doc.phone_number = formatPhoneWithFlag(account_info_ret.data.phone_number, account_info_ret.data.country);
2508
+ } catch (err) {
2509
+ console.error(err);
2510
+ doc.phone_number = account_info_ret.data.phone_number;
2511
+ }
2512
+ }
2513
+
2514
+ if (doc.team_req_id) {
2515
+ try {
2516
+ const req_doc = await db_module.get_couch_doc_native('xuda_team', doc.team_req_id);
2517
+ doc.connection_stat = req_doc.team_req_stat;
2518
+ doc.connection_type = req_doc.access_type;
2519
+ if (doc.connection_type === 'contact_connection') {
2520
+ doc.friend_since = req_doc.team_req_date;
2521
+ }
2522
+ } catch (err) {
2523
+ if (err.message === 'deleted') {
2524
+ try {
2525
+ let contact_doc = await db_module.get_couch_doc_native('xuda_contacts', doc._id);
2526
+ contact_doc.team_req_id = '';
2527
+ await db_module.save_couch_doc('xuda_contacts', contact_doc);
2528
+ } catch (error) {}
2529
+ }
2530
+ doc.connection_stat = 0;
2531
+ }
2532
+ }
2533
+ doc.avatar_source = account_info_ret.data.avatar_source;
2534
+ doc.icon_pattern = await get_contact_pattern(doc);
2535
+ doc.username = account_info_ret.data.username;
2536
+ doc.business_name = account_info_ret.data.business_name;
2537
+ doc.address = account_info_ret.data.address;
2538
+ doc.city = account_info_ret.data.city;
2539
+ doc.state = account_info_ret.data.state;
2540
+ doc.zip = account_info_ret.data.zip;
2541
+ doc.account_type = account_info_ret.data.account_type;
2542
+ doc.email = doc.email?.[0];
2543
+ if (doc.connection_stat === 3) {
2544
+ doc.online = account_info_ret.data.online;
2545
+ }
2546
+
2547
+ doc.interactions = 0;
2548
+ doc.chats = 0;
2549
+
2550
+ const chats_ret = await ai_module.get_ai_chats({ uid, reference_id: doc._id });
2551
+ for (let chat_doc of chats_ret.data.docs) {
2552
+ doc.notifications += chat_doc.notifications;
2553
+
2554
+ doc.chats++;
2555
+ if (chat_doc.interactions) {
2556
+ doc.interactions += chat_doc.interactions;
2557
+ }
2558
+ doc.contact_mood_level = chat_doc.mood_level || 0;
2559
+ }
2560
+
2561
+ doc.card_background = get_contact_background(doc);
2562
+
2563
+ doc.border = get_contact_border(doc);
2564
+
2565
+ return doc;
2566
+ };
2567
+
2486
2568
  export const get_account_profiles = async function (req) {
2487
2569
  const { _id, uid, profile_name, limit, skip, bookmark, search, filter_type = 'all', profile_id } = req;
2488
2570
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/account_module",
3
- "version": "1.2.1061",
3
+ "version": "1.2.1062",
4
4
  "description": "Xuda Account Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {