|
|
|
|
@ -2,7 +2,7 @@
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
'use strict';
|
|
|
|
|
const { objectMapper, pick } = require('../utils/commons.util');
|
|
|
|
|
const { objectMapper, pick, isEmpty } = require('../utils/commons.util');
|
|
|
|
|
|
|
|
|
|
const mediaMsg = {
|
|
|
|
|
contentToSend: msg => {
|
|
|
|
|
@ -48,7 +48,7 @@ const mediaMsg = {
|
|
|
|
|
IVADS_link: msgcontent[msgtype].link,
|
|
|
|
|
IVADS_caption: msgcontent[msgtype].caption || '',
|
|
|
|
|
IVADS_filename: msgcontent[msgtype].filename || '',
|
|
|
|
|
...(msgcontent.context
|
|
|
|
|
...(!isEmpty(msgcontent.context)
|
|
|
|
|
? {
|
|
|
|
|
context_id: msgcontent.context.message_id,
|
|
|
|
|
context_from: msgcontent.message_origin.from,
|
|
|
|
|
@ -67,7 +67,7 @@ const mediaMsg = {
|
|
|
|
|
mime_type: row.IVADS_mime_type ?? '',
|
|
|
|
|
},
|
|
|
|
|
type: row.msgtype,
|
|
|
|
|
...(row.context_id ? { context: { id: row.context_id, from: row.context_from } } : {}),
|
|
|
|
|
...(!isEmpty(row.context_id) ? { context: { id: row.context_id, from: row.context_from } } : {}),
|
|
|
|
|
}),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@ -89,14 +89,14 @@ const waiMsgTypeMapped = {
|
|
|
|
|
externalId: msg.actionId,
|
|
|
|
|
text: msg.msgcontent.body,
|
|
|
|
|
// linkPreview: true, // {}
|
|
|
|
|
...(msg.msgcontent.context ? { quoted: { key: msg.msgcontent.context.message_id } } : {}),
|
|
|
|
|
...(!isEmpty(msg.msgcontent.context) ? { quoted: { key: msg.msgcontent.context.message_id } } : {}),
|
|
|
|
|
}),
|
|
|
|
|
waiContentToDB: msg => {
|
|
|
|
|
return {
|
|
|
|
|
text_body: msg.text.body,
|
|
|
|
|
actionId: msg?.externalId,
|
|
|
|
|
externalId: (msg?.externalId || '').split('.')?.[0],
|
|
|
|
|
...(msg.context
|
|
|
|
|
...(!isEmpty(msg.context)
|
|
|
|
|
? {
|
|
|
|
|
context_id: msg.context.id,
|
|
|
|
|
context_from: msg.context.from,
|
|
|
|
|
@ -115,7 +115,7 @@ const waiMsgTypeMapped = {
|
|
|
|
|
...record,
|
|
|
|
|
text_body: msgcontent.body,
|
|
|
|
|
text_preview_url: msgcontent.preview_url,
|
|
|
|
|
...(msgcontent.context
|
|
|
|
|
...(!isEmpty(msgcontent.context)
|
|
|
|
|
? {
|
|
|
|
|
context_id: msgcontent.context.message_id,
|
|
|
|
|
context_from: msgcontent.message_origin.from,
|
|
|
|
|
@ -127,7 +127,7 @@ const waiMsgTypeMapped = {
|
|
|
|
|
DbData: row => ({
|
|
|
|
|
type: 'text',
|
|
|
|
|
text: { body: row.text_body, preview_url: row.text_preview_url },
|
|
|
|
|
...(row.context_id ? { context: { id: row.context_id, from: row.context_from } } : {}),
|
|
|
|
|
...(!isEmpty(row.context_id) ? { context: { id: row.context_id, from: row.context_from } } : {}),
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
image: {
|
|
|
|
|
|