@xuda.io/ai_module 1.1.3871 → 1.1.3873

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 +19 -16
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -4031,12 +4031,12 @@ export const create_conversation = async function (req, job_id, headers) {
4031
4031
  };
4032
4032
  const save_ret = await db_module.save_app_couch_doc(app_id, conversation_doc);
4033
4033
 
4034
- let contact_uid_chat_conversation;
4034
+ let contact_uid_chat_conversation, receiver_contact_id, receiver_contact_doc;
4035
4035
 
4036
4036
  if (conversation_doc.reference_type === 'contacts') {
4037
4037
  // reference_id is the contact id
4038
- const receiver_contact_id = reference_id;
4039
- const receiver_contact_doc = await account_module.get_contact_info(uid, null, receiver_contact_id);
4038
+ receiver_contact_id = reference_id;
4039
+ receiver_contact_doc = await account_module.get_contact_info(uid, null, receiver_contact_id);
4040
4040
  if (conversation_type === 'chat') {
4041
4041
  if (receiver_contact_doc?.connection_stat !== 3) {
4042
4042
  throw new Error('chat conversation to the recipient is not available');
@@ -4069,23 +4069,26 @@ export const create_conversation = async function (req, job_id, headers) {
4069
4069
 
4070
4070
  await update_thumbnail('conversation', conversation_doc, app_id, uid, job_id, headers);
4071
4071
 
4072
- if (contact_uid_chat_conversation) {
4073
- // write conversation to host after thumbnail update
4074
- // get sender conversation
4072
+ if (conversation_doc.reference_type === 'contacts') {
4073
+ if (contact_uid_chat_conversation) {
4074
+ // write conversation to host after thumbnail update
4075
+ // get sender conversation
4075
4076
 
4076
- const sender_conversation_doc = await db_module.get_app_couch_doc_native(app_id, conversation_obj.id);
4077
- const receiver_app_id = await account_module.get_account_default_project_id(contact_uid_chat_conversation);
4077
+ const sender_conversation_doc = await db_module.get_app_couch_doc_native(app_id, conversation_obj.id);
4078
+ const receiver_app_id = await account_module.get_account_default_project_id(contact_uid_chat_conversation);
4078
4079
 
4079
- let receiver_conversation_doc = await db_module.get_app_couch_doc_native(receiver_app_id, conversation_obj.id);
4080
- receiver_conversation_doc.title = sender_conversation_doc.title;
4080
+ let receiver_conversation_doc = await db_module.get_app_couch_doc_native(receiver_app_id, conversation_obj.id);
4081
+ receiver_conversation_doc.title = sender_conversation_doc.title;
4081
4082
 
4082
- receiver_conversation_doc.thumbnail_request_ts = sender_conversation_doc.thumbnail_request_ts;
4083
- receiver_conversation_doc.chat_image = sender_conversation_doc.chat_image;
4084
- await db_module.save_app_couch_doc_native(receiver_app_id, receiver_conversation_doc);
4083
+ receiver_conversation_doc.thumbnail_request_ts = sender_conversation_doc.thumbnail_request_ts;
4084
+ receiver_conversation_doc.chat_image = sender_conversation_doc.chat_image;
4085
+ await db_module.save_app_couch_doc_native(receiver_app_id, receiver_conversation_doc);
4085
4086
 
4086
- await update_conversation_mood_level(conversation_obj.id, prompt, uid, contact_uid_chat_conversation, true);
4087
- } else {
4088
- await update_conversation_mood_level(conversation_obj.id, prompt, null, receiver_contact_doc.contact_uid, conversation_doc.reference_type === 'contacts');
4087
+ await update_conversation_mood_level(conversation_obj.id, prompt, uid, contact_uid_chat_conversation, true);
4088
+ } else {
4089
+ // other cases rather then chat
4090
+ await update_conversation_mood_level(conversation_obj.id, prompt, null, receiver_contact_doc.contact_uid, conversation_doc.reference_type === 'contacts');
4091
+ }
4089
4092
  }
4090
4093
  }, 1000);
4091
4094
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.3871",
3
+ "version": "1.1.3873",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",