|
|
@ -1,4 +1,4 @@
|
|
|
|
import { cloneDeep, isEmpty, olog, fixTo2Decimals, pick } from "@/utils/commons";
|
|
|
|
import { cloneDeep, isEmpty, olog, fixTo2Decimals, pick, objectMapper } from "@/utils/commons";
|
|
|
|
import dayjs from "dayjs";
|
|
|
|
import dayjs from "dayjs";
|
|
|
|
import { v4 as uuid } from "uuid";
|
|
|
|
import { v4 as uuid } from "uuid";
|
|
|
|
|
|
|
|
|
|
|
@ -322,6 +322,45 @@ const whatsappMsgMapped = {
|
|
|
|
dateString: msgcontent.status==='failed' ? `发送失败 ${whatsappError?.[msgcontent.errorCode] || msgcontent.errorMessage || ''} ❌` : '',
|
|
|
|
dateString: msgcontent.status==='failed' ? `发送失败 ${whatsappError?.[msgcontent.errorCode] || msgcontent.errorMessage || ''} ❌` : '',
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'wai.message.received': {
|
|
|
|
|
|
|
|
getMsg: (result) => {
|
|
|
|
|
|
|
|
const data1 = pick(result, ['conversationid', 'opi_sn', 'coli_sn', 'coli_id']);
|
|
|
|
|
|
|
|
return isEmpty(result?.waiMessage) ? null : { ...result.waiMessage, ...data1, messageorigin: result.messageorigin, msg_source: 'wai', ...objectMapper(result.waiMessage, { direction: 'msg_direction' }) };
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
contentToRender: (contentObj) => {
|
|
|
|
|
|
|
|
return parseRenderMessageItem(contentObj);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
contentToUpdate: () => null,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
'wai.message.updated': {
|
|
|
|
|
|
|
|
getMsg: (result) => {
|
|
|
|
|
|
|
|
return isEmpty(result?.waiMessage)
|
|
|
|
|
|
|
|
? null
|
|
|
|
|
|
|
|
: { ...result.waiMessage, conversationid: result.conversationid, messageorigin: result.messageorigin, msg_source: 'wai', ...objectMapper(result.waiMessage, { direction: 'msg_direction' }) }
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
contentToRender: (contentObj) => {
|
|
|
|
|
|
|
|
if (contentObj?.status === 'failed') {
|
|
|
|
|
|
|
|
contentObj = {
|
|
|
|
|
|
|
|
...contentObj,
|
|
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
|
|
text: { body: `❌` }, // contentObj.errorMessage // Message failed to send.
|
|
|
|
|
|
|
|
id: contentObj.id,
|
|
|
|
|
|
|
|
wamid: contentObj.id,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
return parseRenderMessageItem(contentObj);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// * 仅更新消息状态, 没有输出
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
contentToUpdate: (msgcontent) => ({
|
|
|
|
|
|
|
|
...msgcontent,
|
|
|
|
|
|
|
|
...parseRenderMessageItem(msgcontent),
|
|
|
|
|
|
|
|
id: msgcontent.wamid,
|
|
|
|
|
|
|
|
status: msgStatusRenderMapped[(msgcontent?.status || 'failed')],
|
|
|
|
|
|
|
|
sender: msgcontent.msg_direction === 'outbound' ? 'me' : (msgcontent?.customerProfile ?.name || ''),
|
|
|
|
|
|
|
|
dateString: msgcontent.status==='failed' ? `发送失败 ❌` : '',
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
const emailMsgMapped = {
|
|
|
|
const emailMsgMapped = {
|
|
|
|
'email.inbound.received': {
|
|
|
|
'email.inbound.received': {
|
|
|
|