@xuda.io/ai_module 1.1.4422 → 1.1.4425

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 (3) hide show
  1. package/index.mjs +0 -83
  2. package/old.mjs +45 -0
  3. package/package.json +1 -1
package/index.mjs CHANGED
@@ -4197,29 +4197,10 @@ export const create_conversation = async function (req, job_id, headers) {
4197
4197
  }
4198
4198
  // write conversation to receiver
4199
4199
  recipient_contact_id = contact_doc.connection_contact_id;
4200
- // const sender_contact_ret = await db_module.get_couch_view_raw('xuda_contacts', 'contacts_by_contact_uid', { key: [receiver_contact_doc.contact_uid, uid] });
4201
-
4202
- // const opt = {
4203
- // selector: {
4204
- // docType: 'contact',
4205
- // stat: 3,
4206
- // contact_uid: uid,
4207
- // },
4208
- // limit: 1,
4209
- // fields: ['_id'],
4210
- // };
4211
- // const recipient_contact_ret = await account_module.find_contact_query(receiver_contact_doc.contact_uid, opt);
4212
-
4213
- // if (!recipient_contact_ret?.docs?.length) {
4214
- // throw new Error('sender contact id not found');
4215
- // }
4216
- // const recipient_contact_id = sender_contact_ret?.docs[0]._id;
4217
-
4218
4200
  recipient_uid = contact_doc.connection_uid;
4219
4201
 
4220
4202
  const app_id = await account_module.get_account_default_project_id(recipient_uid);
4221
4203
  const save_ret = await db_module.save_app_couch_doc(app_id, { ...conversation_doc, ...{ uid: recipient_uid, reference_id: recipient_contact_id } });
4222
- // contact_uid_chat_conversation = recipient_uid;
4223
4204
  }
4224
4205
 
4225
4206
  setTimeout(async () => {
@@ -4387,70 +4368,6 @@ const update_conversation_mood_level = async function (uid, target_contacts = []
4387
4368
  await account_module.save_contact(target.uid, contact_doc);
4388
4369
  }
4389
4370
  }
4390
-
4391
- // //////// Sender
4392
- // if (sender_uid) {
4393
- // const sender_app_id = await account_module.get_account_default_project_id(sender_uid);
4394
-
4395
- // let sender_conversation_doc = await db_module.get_app_couch_doc_native(sender_app_id, conversation_id);
4396
- // sender_conversation_doc.mood_level = mood_level_obj.mood_level;
4397
- // await db_module.save_app_couch_doc_native(sender_app_id, sender_conversation_doc);
4398
-
4399
- // if (update_contact) {
4400
- // // const sender_contact_ret = await db_module.get_couch_view_raw('xuda_contacts', 'contacts_by_contact_uid', { key: [receiver_uid, sender_uid] });
4401
-
4402
- // const opt = {
4403
- // selector: {
4404
- // docType: 'contact',
4405
- // stat: 3,
4406
- // contact_uid: sender_uid,
4407
- // },
4408
- // limit: 1,
4409
- // fields: ['_id'],
4410
- // };
4411
- // const sender_contact_ret = await account_module.find_contact_query(receiver_uid, opt);
4412
-
4413
- // if (!sender_contact_ret?.docs?.length) {
4414
- // throw new Error('sender contact id not found');
4415
- // }
4416
- // const sender_contact_id = sender_contact_ret?.docs[0]._id;
4417
- // let sender_contact_doc = await account_module.get_contact(sender_uid, sender_contact_id);
4418
- // sender_contact_doc.contact_mood_level = mood_level_obj.mood_level;
4419
- // sender_contact_doc.ts = Date.now();
4420
- // await account_module.save_contact(sender_uid, sender_contact_doc);
4421
- // }
4422
- // }
4423
- // //////// Receiver
4424
-
4425
- // const receiver_app_id = await account_module.get_account_default_project_id(receiver_uid);
4426
-
4427
- // let receiver_conversation_doc = await db_module.get_app_couch_doc_native(receiver_app_id, conversation_id);
4428
- // receiver_conversation_doc.mood_level = mood_level_obj.mood_level;
4429
- // await db_module.save_app_couch_doc_native(receiver_app_id, receiver_conversation_doc);
4430
-
4431
- // if (update_contact) {
4432
- // // const receiver_contact_ret = await db_module.get_couch_view_raw('xuda_contacts', 'contacts_by_contact_uid', { key: [sender_uid, receiver_uid] });
4433
-
4434
- // const opt = {
4435
- // selector: {
4436
- // docType: 'contact',
4437
- // stat: 3,
4438
- // contact_uid: receiver_uid,
4439
- // },
4440
- // limit: 1,
4441
- // fields: ['_id'],
4442
- // };
4443
- // const receiver_contact_ret = await account_module.find_contact_query(sender_uid, opt);
4444
-
4445
- // if (!receiver_contact_ret?.docs?.length) {
4446
- // throw new Error('receiver contact id not found');
4447
- // }
4448
- // const receiver_contact_id = receiver_contact_ret?.docs[0]._id;
4449
- // let receiver_contact_doc = await account_module.get_contact(receiver_uid, receiver_contact_id);
4450
- // receiver_contact_doc.contact_mood_level = mood_level_obj.mood_level;
4451
- // receiver_contact_doc.ts = Date.now();
4452
- // await account_module.save_contact(receiver_uid, receiver_contact_doc);
4453
- // }
4454
4371
  } catch (err) {
4455
4372
  debugger;
4456
4373
  }
package/old.mjs CHANGED
@@ -2041,3 +2041,48 @@ for await (let account_profile of profile_requests_from_res.docs) {
2041
2041
  // };
2042
2042
 
2043
2043
  // The one-liner wrapper
2044
+
2045
+ // TBD
2046
+ // export const update_contacts_with_account_changes = async function (uid, changes = []) {
2047
+ // try {
2048
+ // if (!changes.length) return;
2049
+ // const ret = await db_module.get_couch_doc('xuda_accounts', uid);
2050
+ // var account_obj = ret.data;
2051
+ // account_obj.ts = Date.now();
2052
+
2053
+ // // update all uid contacts with the new avatar
2054
+ // const opt = {
2055
+ // selector: { contact_uid: uid, docType: 'contact' },
2056
+ // };
2057
+ // debugger;
2058
+ // let changes_made;
2059
+ // var contacts = await db_module.find_couch_query('xuda_contacts', opt);
2060
+ // for (let doc of contacts.docs) {
2061
+ // if (changes.includes('profile_picture')) {
2062
+ // changes_made = true;
2063
+ // doc.profile_picture = account_obj.account_info.profile_picture;
2064
+ // }
2065
+ // if (changes.includes('profile_avatar')) {
2066
+ // changes_made = true;
2067
+ // doc.profile_avatar = account_obj.account_info.profile_avatar;
2068
+ // }
2069
+ // if (changes.includes('email')) {
2070
+ // changes_made = true;
2071
+ // doc.email = account_obj.account_info.email;
2072
+ // }
2073
+ // if (changes.includes('first_name') || changes.includes('last_name')) {
2074
+ // changes_made = true;
2075
+ // doc.name = `${account_obj.account_info.first_name} ${account_obj.account_info.last_name}`;
2076
+ // }
2077
+
2078
+ // console.log(doc);
2079
+ // }
2080
+ // if (contacts.docs && changes_made) {
2081
+ // await db_module.save_couch_bulk_docs('xuda_contacts', contacts.docs);
2082
+ // }
2083
+
2084
+ // return username;
2085
+ // } catch (err) {
2086
+ // return 'unknown';
2087
+ // }
2088
+ // };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4422",
3
+ "version": "1.1.4425",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",