@xuda.io/ai_module 1.1.5051 → 1.1.5053

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 +26 -13
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -1337,6 +1337,18 @@ export const get_ai_chats = async function (req, job_id, headers) {
1337
1337
  descending: false,
1338
1338
  });
1339
1339
 
1340
+ let conversations = {};
1341
+ let docs = [];
1342
+ for (let val of ret.rows || []) {
1343
+ const _conversation = conversations[val.value.conversation_id];
1344
+
1345
+ if (!_conversation) {
1346
+ _conversation[val.value.conversation_id] = {};
1347
+ }
1348
+
1349
+ _conversation[val.value.type] = val.doc;
1350
+ }
1351
+
1340
1352
  return ret;
1341
1353
  };
1342
1354
 
@@ -1409,19 +1421,20 @@ export const get_ai_chats = async function (req, job_id, headers) {
1409
1421
  doc.notifications = contact_chat_conversation_count_ret - contact_chat_conversation_read_ret;
1410
1422
  doc.chats = doc.interactions;
1411
1423
 
1412
- // get conversation item
1413
- let opt = {
1414
- selector: {
1415
- docType: 'chat_conversation_item',
1416
- conversation_id: doc._id,
1417
- },
1418
- limit: 1,
1419
- };
1420
- const conversation_item_ret = await db_module.find_app_couch_query(account_profile_info.app_id, opt);
1421
- doc.conversation_item = conversation_item_ret?.docs?.[0];
1422
- if (doc?.conversation_item?.email_id) {
1423
- doc.email_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, doc.conversation_item.email_id);
1424
- }
1424
+ // // get conversation item
1425
+ // let opt = {
1426
+ // selector: {
1427
+ // docType: 'chat_conversation_item',
1428
+ // conversation_id: doc._id,
1429
+ // },
1430
+ // limit: 1,
1431
+ // };
1432
+ // const conversation_item_ret = await db_module.find_app_couch_query(account_profile_info.app_id, opt);
1433
+ // doc.conversation_item = conversation_item_ret?.docs?.[0];
1434
+ // if (doc?.conversation_item?.email_id) {
1435
+ // doc.email_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, doc.conversation_item.email_id);
1436
+ // }
1437
+
1425
1438
  // doc.notifications = 0;
1426
1439
  // doc.interactions = doc?.messages?.length || 0;
1427
1440
  // for (let msg of doc.messages) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.5051",
3
+ "version": "1.1.5053",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",