@xuda.io/ai_module 1.1.5474 → 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
@@ -1465,7 +1465,6 @@ export const delete_ai_chat = async function (req) {
1465
1465
 
1466
1466
  const account_profile_info = await get_active_account_profile_info(uid);
1467
1467
 
1468
- const app_id = await get_account_default_project_id(uid);
1469
1468
  let conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_id);
1470
1469
 
1471
1470
  let save_ret;
@@ -1527,6 +1526,40 @@ export const archive_ai_chat = async function (req) {
1527
1526
  }
1528
1527
  };
1529
1528
 
1529
+ export const delete_conversation_item = async function (req) {
1530
+ let { conversation_item_id, uid } = req;
1531
+
1532
+ const account_profile_info = await get_active_account_profile_info(uid);
1533
+
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
+
1537
+ let save_ret;
1538
+ try {
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);
1542
+
1543
+ await client.conversations.items.delete(conversation_doc.reference_conversation_id, conversation_item_doc.conversation_item_reference_id);
1544
+
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) {}
1550
+ }
1551
+ }
1552
+
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) }] });
1555
+ }
1556
+
1557
+ return save_ret;
1558
+ } catch (err) {
1559
+ return { code: -3, data: err.message };
1560
+ }
1561
+ };
1562
+
1530
1563
  export const unarchive_ai_chat = async function (req) {
1531
1564
  let { conversation_id, uid } = req;
1532
1565
  const account_profile_info = await get_active_account_profile_info(uid);
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.5474",
3
+ "version": "1.1.5476",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",