@xuda.io/ai_module 1.1.5473 → 1.1.5475

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 +45 -2
  2. package/package.json +1 -1
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,50 @@ 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
+ 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);
1536
+
1537
+ let save_ret;
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);
1551
+
1552
+ client.conversations.delete(conversation_id);
1553
+
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
+ }
1560
+ }
1561
+
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
+ }
1565
+ }
1566
+
1567
+ return save_ret;
1568
+ } catch (err) {
1569
+ return { code: -3, data: err.message };
1570
+ }
1571
+ };
1572
+
1530
1573
  export const unarchive_ai_chat = async function (req) {
1531
1574
  let { conversation_id, uid } = req;
1532
1575
  const account_profile_info = await get_active_account_profile_info(uid);
@@ -2242,7 +2285,7 @@ export const archive_mini_app = async function (req) {
2242
2285
 
2243
2286
  let prog_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, prog_id);
2244
2287
 
2245
- if (agent_doc.studio_meta.createdByUid !== uid && agent_doc?.studio_meta?.account_profile_info?.uid !== uid) {
2288
+ if (prog_doc.studio_meta.createdByUid !== uid && prog_doc?.studio_meta?.account_profile_info?.uid !== uid) {
2246
2289
  throw new Error('Operation not allowed');
2247
2290
  }
2248
2291
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.5473",
3
+ "version": "1.1.5475",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",