@xuda.io/ai_module 1.1.4625 → 1.1.4627
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 +34 -8
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1786,8 +1786,6 @@ export const get_ai_chats = async function (req, job_id, headers) {
|
|
|
1786
1786
|
};
|
|
1787
1787
|
|
|
1788
1788
|
try {
|
|
1789
|
-
// if (_id) return await get_studio_doc({ _id, uid });
|
|
1790
|
-
|
|
1791
1789
|
if (_id) {
|
|
1792
1790
|
const app_id = await account_module.get_account_default_project_id(uid);
|
|
1793
1791
|
let data = await db_module.get_app_couch_doc(account_profile_info.app_id, _id);
|
|
@@ -1867,7 +1865,28 @@ export const get_ai_chats = async function (req, job_id, headers) {
|
|
|
1867
1865
|
};
|
|
1868
1866
|
}
|
|
1869
1867
|
|
|
1870
|
-
|
|
1868
|
+
const chat_conversation_count = async function (_id) {
|
|
1869
|
+
const counts_ret = await db_module.get_app_couch_view(account_profile_info.app_id, 'chat_conversation_item_counts', {
|
|
1870
|
+
reduce: true,
|
|
1871
|
+
group_level: 1,
|
|
1872
|
+
|
|
1873
|
+
startkey: [_id, ''],
|
|
1874
|
+
endkey: [_id, 'zzzzzz'],
|
|
1875
|
+
});
|
|
1876
|
+
|
|
1877
|
+
return counts_ret?.rows?.[0]?.value || 0;
|
|
1878
|
+
};
|
|
1879
|
+
const chat_conversation_read = async function (_id) {
|
|
1880
|
+
const counts_ret = await db_module.get_app_couch_view(account_profile_info.app_id, 'chat_conversation_item_read', {
|
|
1881
|
+
reduce: true,
|
|
1882
|
+
group_level: 2,
|
|
1883
|
+
|
|
1884
|
+
startkey: [uid, _id, ''],
|
|
1885
|
+
endkey: [uid, _id, 'zzzzzz'],
|
|
1886
|
+
});
|
|
1887
|
+
|
|
1888
|
+
return counts_ret?.rows?.[0]?.value || 0;
|
|
1889
|
+
};
|
|
1871
1890
|
|
|
1872
1891
|
////// FROM - IN
|
|
1873
1892
|
let requests_from = { docs: [], total_docs: 0 };
|
|
@@ -1924,11 +1943,18 @@ export const get_ai_chats = async function (req, job_id, headers) {
|
|
|
1924
1943
|
doc.reference_doc = reference_doc;
|
|
1925
1944
|
}
|
|
1926
1945
|
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1946
|
+
const contact_chat_conversation_count_ret = await chat_conversation_count(doc._id);
|
|
1947
|
+
const contact_chat_conversation_read_ret = await chat_conversation_read(doc._id);
|
|
1948
|
+
|
|
1949
|
+
doc.interactions = contact_chat_conversation_count_ret;
|
|
1950
|
+
doc.notifications = contact_chat_conversation_count_ret - contact_chat_conversation_read_ret;
|
|
1951
|
+
doc.chats = doc.interactions;
|
|
1952
|
+
|
|
1953
|
+
// doc.notifications = 0;
|
|
1954
|
+
// doc.interactions = doc?.messages?.length || 0;
|
|
1955
|
+
// for (let msg of doc.messages) {
|
|
1956
|
+
// if (!msg.read) doc.notifications++;
|
|
1957
|
+
// }
|
|
1932
1958
|
|
|
1933
1959
|
// if (!doc.chat_image && (!doc.thumbnail_request_ts || Date.now() - doc.thumbnail_request_ts > 120000)) {
|
|
1934
1960
|
// if (headers) {
|