@xuda.io/ai_module 1.1.4493 → 1.1.4495
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 +9 -4
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -4385,18 +4385,23 @@ const chat_email = async function (req, job_id, headers) {
|
|
|
4385
4385
|
|
|
4386
4386
|
let sender_conversation_doc = await db_module.get_app_couch_doc_native(sender_app_id, conversation_id);
|
|
4387
4387
|
|
|
4388
|
+
if (sender_conversation_doc.reference_type !== 'contacts') {
|
|
4389
|
+
throw new Error('not an contact conversation');
|
|
4390
|
+
}
|
|
4391
|
+
|
|
4392
|
+
let sent_email_result = {};
|
|
4393
|
+
|
|
4388
4394
|
// send an email by user invocation
|
|
4389
4395
|
if (!from_mailbox) {
|
|
4390
4396
|
const to = '';
|
|
4391
4397
|
const subject = '';
|
|
4392
|
-
const text = '';
|
|
4393
4398
|
|
|
4394
4399
|
const email_module = await import(`${module_path}/email_module/index.mjs`);
|
|
4395
|
-
const email_ret = email_module.sendEmailFromAccount(email_account_doc, to, subject,
|
|
4400
|
+
const email_ret = email_module.sendEmailFromAccount(email_account_doc, to, subject, body, null, attachments);
|
|
4396
4401
|
if (!email_ret.result) {
|
|
4397
4402
|
throw new Error('error sending email');
|
|
4398
4403
|
}
|
|
4399
|
-
|
|
4404
|
+
sent_email_result = email_ret.result;
|
|
4400
4405
|
}
|
|
4401
4406
|
|
|
4402
4407
|
if (perform_ai_execution) {
|
|
@@ -4417,7 +4422,7 @@ const chat_email = async function (req, job_id, headers) {
|
|
|
4417
4422
|
sender_conversation_doc.messages.push(obj);
|
|
4418
4423
|
await db_module.save_app_couch_doc_native(sender_app_id, sender_conversation_doc);
|
|
4419
4424
|
|
|
4420
|
-
const save_ret = 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, email_id });
|
|
4425
|
+
const save_ret = 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, email_id, sent_email_result });
|
|
4421
4426
|
|
|
4422
4427
|
return save_ret;
|
|
4423
4428
|
} catch (err) {
|