@xuda.io/ai_module 1.1.4277 → 1.1.4279

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 +14 -14
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -4175,7 +4175,7 @@ export const create_conversation = async function (req, job_id, headers) {
4175
4175
  };
4176
4176
  const save_ret = await db_module.save_app_couch_doc(account_profile_info.app_id, conversation_doc);
4177
4177
 
4178
- let contact_uid_chat_conversation, contact_id, contact_doc;
4178
+ let contact_id, contact_doc, recipient_uid, recipient_contact_id;
4179
4179
 
4180
4180
  if (conversation_doc.reference_type === 'contacts' && conversation_type === 'chat') {
4181
4181
  // reference_id is the contact id
@@ -4190,7 +4190,7 @@ export const create_conversation = async function (req, job_id, headers) {
4190
4190
  throw new Error('chat conversation to the recipient is not available');
4191
4191
  }
4192
4192
  // write conversation to receiver
4193
- let recipient_contact_id = contact_doc.connection_contact_id;
4193
+ recipient_contact_id = contact_doc.connection_contact_id;
4194
4194
  // const sender_contact_ret = await db_module.get_couch_view_raw('xuda_contacts', 'contacts_by_contact_uid', { key: [receiver_contact_doc.contact_uid, uid] });
4195
4195
 
4196
4196
  // const opt = {
@@ -4209,11 +4209,11 @@ export const create_conversation = async function (req, job_id, headers) {
4209
4209
  // }
4210
4210
  // const recipient_contact_id = sender_contact_ret?.docs[0]._id;
4211
4211
 
4212
- let recipient_uid = contact_doc.connection_uid;
4212
+ recipient_uid = contact_doc.connection_uid;
4213
4213
 
4214
4214
  const app_id = await account_module.get_account_default_project_id(recipient_uid);
4215
4215
  const save_ret = await db_module.save_app_couch_doc(app_id, { ...conversation_doc, ...{ uid: recipient_uid, reference_id: recipient_contact_id } });
4216
- contact_uid_chat_conversation = recipient_uid;
4216
+ // contact_uid_chat_conversation = recipient_uid;
4217
4217
  }
4218
4218
 
4219
4219
  setTimeout(async () => {
@@ -4228,30 +4228,30 @@ export const create_conversation = async function (req, job_id, headers) {
4228
4228
  await update_thumbnail('conversation', conversation_doc, account_profile_info.app_id, uid, job_id, headers, null, null, account_profile_info);
4229
4229
 
4230
4230
  if (conversation_doc.reference_type === 'contacts') {
4231
- if (contact_uid_chat_conversation) {
4231
+ if (recipient_uid) {
4232
4232
  // write conversation to host after thumbnail update
4233
4233
  // get sender conversation
4234
4234
 
4235
- const sender_conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_obj.id);
4236
- const receiver_app_id = await account_module.get_account_default_project_id(contact_uid_chat_conversation);
4235
+ const conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_obj.id);
4237
4236
 
4238
- let receiver_conversation_doc = await db_module.get_app_couch_doc_native(receiver_app_id, conversation_obj.id);
4239
- receiver_conversation_doc.title = sender_conversation_doc.title;
4237
+ const recipient_account_profile_info = await account_module.get_active_account_profile_info(recipient_uid);
4238
+ let recipient_conversation_doc = await db_module.get_app_couch_doc_native(recipient_account_profile_info.app_id, conversation_obj.id);
4239
+ recipient_conversation_doc.title = conversation_doc.title;
4240
4240
 
4241
- receiver_conversation_doc.thumbnail_request_ts = sender_conversation_doc.thumbnail_request_ts;
4242
- receiver_conversation_doc.chat_image = sender_conversation_doc.chat_image;
4243
- await db_module.save_app_couch_doc_native(receiver_app_id, receiver_conversation_doc);
4241
+ recipient_conversation_doc.thumbnail_request_ts = conversation_doc.thumbnail_request_ts;
4242
+ recipient_conversation_doc.chat_image = conversation_doc.chat_image;
4243
+ await db_module.save_app_couch_doc_native(recipient_account_profile_info.app_id, recipient_conversation_doc);
4244
4244
 
4245
4245
  await update_conversation_mood_level(
4246
4246
  uid,
4247
4247
  [
4248
4248
  { uid: account_profile_info.uid, contact_id: reference_id },
4249
- { uid: contact_uid_chat_conversation.uid, contact_id: reference_id },
4249
+ { uid: recipient_uid, contact_id: recipient_contact_id },
4250
4250
  ],
4251
4251
  conversation_obj.id,
4252
4252
  prompt,
4253
4253
  uid,
4254
- contact_uid_chat_conversation,
4254
+ recipient_uid,
4255
4255
  true,
4256
4256
  account_profile_info,
4257
4257
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4277",
3
+ "version": "1.1.4279",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",