@xuda.io/ai_module 1.1.5494 → 1.1.5496
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.
- package/index.mjs +2 -33
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -5112,10 +5112,9 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
5112
5112
|
}
|
|
5113
5113
|
};
|
|
5114
5114
|
|
|
5115
|
-
const add_conversation_item = async function (uid,
|
|
5116
|
-
const { uid, profile_id } = req;
|
|
5115
|
+
const add_conversation_item = async function (uid, profile_id, text, conversation_type, contact_id, metadata = {}) {
|
|
5117
5116
|
const account_profile_info = await get_active_account_profile_info(uid, profile_id);
|
|
5118
|
-
|
|
5117
|
+
|
|
5119
5118
|
try {
|
|
5120
5119
|
const conversation_id = conversation_doc._id;
|
|
5121
5120
|
|
|
@@ -5139,36 +5138,6 @@ const add_conversation_item = async function (uid, contact_id, text, conversatio
|
|
|
5139
5138
|
report_ai_status('conversations', err);
|
|
5140
5139
|
throw err;
|
|
5141
5140
|
}
|
|
5142
|
-
|
|
5143
|
-
// let obj = { id: item.data[0].id, ts: Date.now(), uid, read: true, conversation_type: 'note' };
|
|
5144
|
-
|
|
5145
|
-
// sender_conversation_doc.messages.push(obj);
|
|
5146
|
-
// await db_module.save_app_couch_doc_native(sender_app_id, sender_conversation_doc);
|
|
5147
|
-
|
|
5148
|
-
let out_conversation_item_obj = {
|
|
5149
|
-
_id: await _common.xuda_get_uuid('chat_conversation_item'),
|
|
5150
|
-
stat: 3,
|
|
5151
|
-
docType: 'chat_conversation_item',
|
|
5152
|
-
uid,
|
|
5153
|
-
conversation_type: 'note',
|
|
5154
|
-
type: 'note',
|
|
5155
|
-
date_created_ts: Date.now(),
|
|
5156
|
-
ts: Date.now(),
|
|
5157
|
-
conversation_id,
|
|
5158
|
-
text: body,
|
|
5159
|
-
reference_id: conversation_doc.reference_id,
|
|
5160
|
-
conversation_item_reference_id: item.data[0].id,
|
|
5161
|
-
direction: 'out',
|
|
5162
|
-
role: 'user',
|
|
5163
|
-
read: { [uid]: Date.now() },
|
|
5164
|
-
rtl: _common.detectRTL(body),
|
|
5165
|
-
};
|
|
5166
|
-
|
|
5167
|
-
const save_ret = await db_module.save_app_couch_doc(sender_app_id, out_conversation_item_obj);
|
|
5168
|
-
|
|
5169
|
-
// await db_module.save_app_couch_doc_native(sender_app_id, { _id: obj.id, stat: 3, docType: 'chat_conversation_item', ts: obj.ts, uid, conversation_type: obj.conversation_type, date_created_ts: obj.ts, conversation_id, body, reference_id: conversation_doc.reference_id });
|
|
5170
|
-
|
|
5171
|
-
return save_ret; //{ code: 15, data: item };
|
|
5172
5141
|
} catch (err) {
|
|
5173
5142
|
return { code: -15, data: err.message };
|
|
5174
5143
|
}
|