@xuda.io/ai_module 1.1.5475 → 1.1.5476

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 CHANGED
@@ -1531,37 +1531,27 @@ export const delete_conversation_item = async function (req) {
1531
1531
 
1532
1532
  const account_profile_info = await get_active_account_profile_info(uid);
1533
1533
 
1534
- const app_id = await get_account_default_project_id(uid);
1535
- let conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_id);
1534
+ let conversation_item_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_item_id);
1535
+ let conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_item_doc.conversation_id);
1536
1536
 
1537
1537
  let save_ret;
1538
1538
  try {
1539
- if (conversation_doc.stat !== 5) {
1540
- throw new Error('A document can only be deleted after it has been archived');
1541
- }
1542
-
1543
- if (conversation_doc.shared_from_uid) {
1544
- // delete the share , the doc will delete by the remove_team_member
1545
-
1546
- save_ret = await team_ms.remove_team_member({ team_req_id: conversation_doc.team_req_id });
1547
- } else {
1548
- conversation_doc.stat = 4;
1549
- conversation_doc.ts = Date.now();
1550
- save_ret = await db_module.save_app_couch_doc(account_profile_info.app_id, conversation_doc);
1539
+ conversation_item_doc.stat = 4;
1540
+ conversation_item_doc.ts = Date.now();
1541
+ save_ret = await db_module.save_app_couch_doc(account_profile_info.app_id, conversation_item_doc);
1551
1542
 
1552
- client.conversations.delete(conversation_id);
1543
+ await client.conversations.items.delete(conversation_doc.reference_conversation_id, conversation_item_doc.conversation_item_reference_id);
1553
1544
 
1554
- for (const msg of conversation_doc?.messages || []) {
1555
- for (const attachment of msg?.attachments || []) {
1556
- try {
1557
- if (attachment.id) client.files.delete(attachment.id);
1558
- } catch (error) {}
1559
- }
1545
+ for (const msg of conversation_doc?.messages || []) {
1546
+ for (const attachment of msg?.attachments || []) {
1547
+ try {
1548
+ if (attachment.id) client.files.delete(attachment.id);
1549
+ } catch (error) {}
1560
1550
  }
1551
+ }
1561
1552
 
1562
- if (conversation_doc?.chat_image?.[0]) {
1563
- drive_msa.delete_drive_files({ uid, drive_type: 'user', files_arr: [{ type: 'file', file_path: path.join(conversation_doc.chat_image[0].file_path, conversation_doc.chat_image[0].filename) }] });
1564
- }
1553
+ if (conversation_doc?.chat_image?.[0]) {
1554
+ drive_msa.delete_drive_files({ uid, drive_type: 'user', files_arr: [{ type: 'file', file_path: path.join(conversation_doc.chat_image[0].file_path, conversation_doc.chat_image[0].filename) }] });
1565
1555
  }
1566
1556
 
1567
1557
  return save_ret;
package/index_ms.mjs CHANGED
@@ -33,6 +33,10 @@ export const archive_ai_chat = async function (...args) {
33
33
  return await broker.send_to_queue("archive_ai_chat", ...args);
34
34
  };
35
35
 
36
+ export const delete_conversation_item = async function (...args) {
37
+ return await broker.send_to_queue("delete_conversation_item", ...args);
38
+ };
39
+
36
40
  export const unarchive_ai_chat = async function (...args) {
37
41
  return await broker.send_to_queue("unarchive_ai_chat", ...args);
38
42
  };
package/index_msa.mjs CHANGED
@@ -33,6 +33,10 @@ export const archive_ai_chat = function (...args) {
33
33
  broker.send_to_queue_async("archive_ai_chat", ...args);
34
34
  };
35
35
 
36
+ export const delete_conversation_item = function (...args) {
37
+ broker.send_to_queue_async("delete_conversation_item", ...args);
38
+ };
39
+
36
40
  export const unarchive_ai_chat = function (...args) {
37
41
  broker.send_to_queue_async("unarchive_ai_chat", ...args);
38
42
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.5475",
3
+ "version": "1.1.5476",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",