@xuda.io/ai_module 1.1.4629 → 1.1.4631

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 +13 -6
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -1730,10 +1730,10 @@ export const get_chat_conversation = async function (req) {
1730
1730
  conversation_doc = await db_module.get_app_couch_doc_native(reference_doc.shared_from_app_id, reference_doc.share_item_id);
1731
1731
  conversation_doc.reference_doc = reference_doc;
1732
1732
  }
1733
- let conversation = await db_module.find_app_couch_query(account_profile_info.app_id, {
1733
+ let conversation_items = await db_module.find_app_couch_query(account_profile_info.app_id, {
1734
1734
  selector: {
1735
1735
  docType: 'chat_conversation_item',
1736
- conversation_id: conversation_id,
1736
+ conversation_id,
1737
1737
  stat: 3,
1738
1738
  },
1739
1739
  limit,
@@ -1741,7 +1741,14 @@ export const get_chat_conversation = async function (req) {
1741
1741
  sort: ['date_created_ts'],
1742
1742
  });
1743
1743
 
1744
- return { code: 15, data: { conversation, ...conversation_doc } };
1744
+ for (let conversation_item_doc of conversation_items.docs || []) {
1745
+ if (!conversation_item_doc.read) {
1746
+ conversation_item_doc.read = {};
1747
+ }
1748
+ conversation_item_doc.read[uid] = Date.now();
1749
+ }
1750
+
1751
+ return { code: 15, data: { conversation_items, ...conversation_doc } };
1745
1752
  } catch (err) {
1746
1753
  return { code: -15, data: err.message };
1747
1754
  }
@@ -1878,7 +1885,7 @@ export const get_ai_chats = async function (req, job_id, headers) {
1878
1885
 
1879
1886
  return counts_ret?.rows?.[0]?.value || 0;
1880
1887
  };
1881
- const chat_conversation_read = async function (_id) {
1888
+ const chat_conversation_read = async function (contact_id, conversation_id) {
1882
1889
  const counts_ret = await db_module.get_app_couch_view(account_profile_info.app_id, 'chat_conversation_item_read', {
1883
1890
  reduce: true,
1884
1891
  group_level: 2,
@@ -1946,8 +1953,8 @@ export const get_ai_chats = async function (req, job_id, headers) {
1946
1953
  doc.reference_doc = reference_doc;
1947
1954
  }
1948
1955
 
1949
- const contact_chat_conversation_count_ret = await chat_conversation_count(doc._id);
1950
- const contact_chat_conversation_read_ret = await chat_conversation_read(doc._id);
1956
+ const contact_chat_conversation_count_ret = await chat_conversation_count(doc.reference_id, doc._id);
1957
+ const contact_chat_conversation_read_ret = await chat_conversation_read(doc.reference_id, doc._id);
1951
1958
 
1952
1959
  doc.interactions = contact_chat_conversation_count_ret;
1953
1960
  doc.notifications = contact_chat_conversation_count_ret - contact_chat_conversation_read_ret;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4629",
3
+ "version": "1.1.4631",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",