@xuda.io/ai_module 1.1.4265 → 1.1.4267

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 +31 -0
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -4366,6 +4366,37 @@ const update_conversation_mood_level = async function (uid, target_contacts = []
4366
4366
 
4367
4367
  const mood_level_obj = JSON5.parse(mood_level.data);
4368
4368
 
4369
+ for await (const target of target_contacts) {
4370
+ const account_profile_info = await account_module.get_active_account_profile_info(target.uid);
4371
+ let conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_id);
4372
+ conversation_doc.mood_level = mood_level_obj.mood_level;
4373
+ await db_module.save_app_couch_doc_native(account_profile_info.app_id, conversation_doc);
4374
+
4375
+ if (update_contact) {
4376
+ // const sender_contact_ret = await db_module.get_couch_view_raw('xuda_contacts', 'contacts_by_contact_uid', { key: [receiver_uid, sender_uid] });
4377
+
4378
+ const opt = {
4379
+ selector: {
4380
+ docType: 'contact',
4381
+ stat: 3,
4382
+ contact_uid: sender_uid,
4383
+ },
4384
+ limit: 1,
4385
+ fields: ['_id'],
4386
+ };
4387
+ const sender_contact_ret = await account_module.find_contact_query(receiver_uid, opt);
4388
+
4389
+ if (!sender_contact_ret?.docs?.length) {
4390
+ throw new Error('sender contact id not found');
4391
+ }
4392
+ const sender_contact_id = sender_contact_ret?.docs[0]._id;
4393
+ let sender_contact_doc = await account_module.get_contact(sender_uid, sender_contact_id);
4394
+ sender_contact_doc.contact_mood_level = mood_level_obj.mood_level;
4395
+ sender_contact_doc.ts = Date.now();
4396
+ await account_module.save_contact(sender_uid, sender_contact_doc);
4397
+ }
4398
+ }
4399
+
4369
4400
  //////// Sender
4370
4401
  if (sender_uid) {
4371
4402
  const sender_app_id = await account_module.get_account_default_project_id(sender_uid);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4265",
3
+ "version": "1.1.4267",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",