@xuda.io/account_module 1.2.2136 → 1.2.2138

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 +16 -7
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -2332,7 +2332,7 @@ export const get_contacts = async function (req, job_id, headers) {
2332
2332
  let contact_docs = { docs: [], total_docs: contacts.total_docs };
2333
2333
 
2334
2334
  const chat_conversation_count = async function () {
2335
- const account_profile_info = await get_active_account_profile_info(uid);
2335
+ // const account_profile_info = await get_active_account_profile_info(uid);
2336
2336
 
2337
2337
  const counts_ret = await db_module.get_app_couch_view(account_profile_info.app_id, 'conversations_item_counts', {
2338
2338
  reduce: true,
@@ -2352,20 +2352,25 @@ export const get_contacts = async function (req, job_id, headers) {
2352
2352
  return counts;
2353
2353
  };
2354
2354
  const chat_conversation_read = async function () {
2355
- const account_profile_info = await get_active_account_profile_info(uid);
2355
+ // const account_profile_info = await get_active_account_profile_info(uid);
2356
2356
 
2357
2357
  const counts_ret = await db_module.get_app_couch_view(account_profile_info.app_id, 'chat_conversation_item_read', {
2358
2358
  reduce: true,
2359
- group_level: 2,
2359
+ group_level: 1,
2360
2360
 
2361
- startkey: [uid, doc._id, ''],
2362
- endkey: [uid, doc._id, 'zzzzzz'],
2361
+ startkey: [uid, '', ''],
2362
+ endkey: [uid, '', 'zzzzzz'],
2363
2363
  });
2364
2364
 
2365
- return counts_ret?.rows?.[0]?.value || 0;
2365
+ let counts = {};
2366
+ for (const val of counts_ret?.rows) {
2367
+ counts[val.key[2]] = val.value;
2368
+ }
2369
+ return counts;
2366
2370
  };
2367
2371
 
2368
- const conversation_count = await chat_conversation_count();
2372
+ const contact_chat_conversation_count_ret = await chat_conversation_count();
2373
+ const contact_chat_conversation_read_ret = await chat_conversation_read();
2369
2374
  debugger;
2370
2375
  for await (let doc of contacts.docs) {
2371
2376
  const ret_to = requests_to.docs.find((e) => {
@@ -2380,6 +2385,10 @@ export const get_contacts = async function (req, job_id, headers) {
2380
2385
 
2381
2386
  doc = await get_contact_info(uid, doc);
2382
2387
 
2388
+ doc.interactions = contact_chat_conversation_count_ret[doc._id];
2389
+ doc.notifications = contact_chat_conversation_count_ret[doc._id] - contact_chat_conversation_read_ret[doc._id];
2390
+ doc.chats = doc.interactions;
2391
+
2383
2392
  if (filter_type === 'online') {
2384
2393
  if (!doc.online) continue;
2385
2394
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/account_module",
3
- "version": "1.2.2136",
3
+ "version": "1.2.2138",
4
4
  "description": "Xuda Account Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {