|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
import { cloneDeep, isEmpty, olog, fixTo2Decimals } from "@/utils/commons";
|
|
|
|
|
import { cloneDeep, isEmpty, olog, fixTo2Decimals, pick } from "@/utils/commons";
|
|
|
|
|
import dayjs from "dayjs";
|
|
|
|
|
import { v4 as uuid } from "uuid";
|
|
|
|
|
|
|
|
|
@ -282,7 +282,8 @@ const emailMsgMapped = {
|
|
|
|
|
'email.inbound.received': {
|
|
|
|
|
getMsg: (result) => {
|
|
|
|
|
console.log('email.inbound.received', result);
|
|
|
|
|
return isEmpty(result?.emailMessage) ? null : { ...result.emailMessage, conversationid: result.conversationid, };
|
|
|
|
|
const data1 = pick(result, ['conversationid', 'opi_sn', 'coli_sn', 'coli_id']);
|
|
|
|
|
return isEmpty(result?.emailMessage) ? null : { ...result.emailMessage, ...data1, };
|
|
|
|
|
},
|
|
|
|
|
contentToRender: (contentObj) => {
|
|
|
|
|
// console.log('email.inbound.received to render', contentObj);
|
|
|
|
@ -295,7 +296,8 @@ const emailMsgMapped = {
|
|
|
|
|
getMsg: (result) => {
|
|
|
|
|
console.log('email.updated', result);
|
|
|
|
|
const { emailMessage } = result;
|
|
|
|
|
return isEmpty(result?.emailMessage) ? null : { ...emailMessage, conversationid: result.conversationid, };
|
|
|
|
|
const data1 = pick(result, ['conversationid', 'opi_sn', 'coli_sn', 'coli_id']);
|
|
|
|
|
return isEmpty(result?.emailMessage) ? null : { ...emailMessage, ...data1, };
|
|
|
|
|
},
|
|
|
|
|
contentToRender: (contentObj) => null,
|
|
|
|
|
contentToUpdate: (msgcontent) => ({
|
|
|
|
@ -398,24 +400,24 @@ export const whatsappMsgTypeMapped = {
|
|
|
|
|
},
|
|
|
|
|
text: {
|
|
|
|
|
type: 'text',
|
|
|
|
|
data: (msg) => ({ id: msg.wamid, text: autoLinkText(msg?.text?.body), originText: msg?.text?.body, title: msg?.customerProfile?.name || '' }),
|
|
|
|
|
data: (msg) => ({ id: msg.wamid, text: autoLinkText(msg?.text?.body), originText: msg?.text?.body, title: msg?.customerProfile?.name || msg?.from || '' }),
|
|
|
|
|
renderForReply: (msg) => ({ id: msg.wamid, message: msg?.text?.body }),
|
|
|
|
|
},
|
|
|
|
|
image: {
|
|
|
|
|
type: 'photo',
|
|
|
|
|
data: (msg) => ({
|
|
|
|
|
id: msg.wamid,
|
|
|
|
|
text: msg.image.caption,
|
|
|
|
|
text: msg.image?.caption,
|
|
|
|
|
onPhotoError: ({ currentTarget }) => {
|
|
|
|
|
currentTarget.onerror = null;
|
|
|
|
|
currentTarget.src="https://hiana-crm.oss-accelerate.aliyuncs.com/WAMedia/afe412d4-3acf-4e79-a623-048aeb4d696a.png";
|
|
|
|
|
},
|
|
|
|
|
data: {
|
|
|
|
|
id: msg.wamid,
|
|
|
|
|
uri: msg.image.link,
|
|
|
|
|
uri: msg.image?.link,
|
|
|
|
|
width: 'auto',
|
|
|
|
|
height: 200,
|
|
|
|
|
alt: msg.image.caption || '',
|
|
|
|
|
alt: msg.image?.caption || '',
|
|
|
|
|
status: {
|
|
|
|
|
click: true,
|
|
|
|
|
loading: 0,
|
|
|
|
@ -426,7 +428,7 @@ export const whatsappMsgTypeMapped = {
|
|
|
|
|
}),
|
|
|
|
|
renderForReply: (msg) => ({
|
|
|
|
|
id: msg.wamid,
|
|
|
|
|
photoURL: msg.image.link,
|
|
|
|
|
photoURL: msg.image?.link,
|
|
|
|
|
width: 'auto',
|
|
|
|
|
height: 200,
|
|
|
|
|
alt: msg.image?.caption || '',
|
|
|
|
@ -439,7 +441,7 @@ export const whatsappMsgTypeMapped = {
|
|
|
|
|
id: msg.wamid,
|
|
|
|
|
data: {
|
|
|
|
|
id: msg.wamid,
|
|
|
|
|
uri: msg.sticker.link,
|
|
|
|
|
uri: msg.sticker?.link,
|
|
|
|
|
width: '100%',
|
|
|
|
|
height: 120,
|
|
|
|
|
alt: '',
|
|
|
|
@ -602,8 +604,7 @@ export const parseRenderMessageItem = (msg) => {
|
|
|
|
|
dateString: dayjs(msg?.sendTime || msg.createTime).format('MM-DD HH:mm'),
|
|
|
|
|
from: msg.from,
|
|
|
|
|
sender: msg.from,
|
|
|
|
|
senderName: msg?.customerProfile?.name || msg?.fromName || msg?.from || 'me', // msg.from,
|
|
|
|
|
// title: msg.customerProfile.name,
|
|
|
|
|
senderName: msg?.customerProfile?.name || msg?.fromName || msg?.from || 'me',
|
|
|
|
|
customer_name: msg?.customerProfile?.name || '',
|
|
|
|
|
whatsapp_name: msg?.customerProfile?.name || '',
|
|
|
|
|
whatsapp_phone_number: isEmpty(msg?.customerProfile) ? msg.to : msg.from,
|
|
|
|
@ -665,23 +666,20 @@ export const parseRenderMessageList = (messages) => {
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
...msg,
|
|
|
|
|
msgOrigin: {...msgContent, ...msgContent.email},
|
|
|
|
|
msgOrigin: { ...msgContent, ...msgContent.email },
|
|
|
|
|
...(whatsappMsgTypeMapped?.[msgType]?.data(msgContent) || {}),
|
|
|
|
|
type: msgContent.type,
|
|
|
|
|
...(typeof whatsappMsgTypeMapped[msgType].type === 'function' ? whatsappMsgTypeMapped[msgType].type(msg) : { type: whatsappMsgTypeMapped[msgType].type || 'text' }),
|
|
|
|
|
date: msgContent?.sendTime || msg.msgtime || '',
|
|
|
|
|
dateText: dayjs(msgContent?.sendTime || msg.msgtime).format('MM-DD HH:mm'),
|
|
|
|
|
dateString: dayjs(msgContent?.sendTime || msg.msgtime).format('MM-DD HH:mm'),
|
|
|
|
|
date: msg.msgtime, // msgContent?.sendTime || msg.msgtime || '',
|
|
|
|
|
dateText: dayjs(msg.msgtime).format('MM-DD HH:mm'),
|
|
|
|
|
dateString: dayjs(msg.msgtime).format('MM-DD HH:mm'),
|
|
|
|
|
localDate: (msg.msgtime || '').replace('T', ' '),
|
|
|
|
|
from: msgContent.from,
|
|
|
|
|
sender: msgContent.from,
|
|
|
|
|
senderName: msgContent?.customerProfile?.name || 'me', // msgContent.from,
|
|
|
|
|
senderName: msgContent?.customerProfile?.name || msgContent.from || 'me',
|
|
|
|
|
replyButton: ['text', 'document', 'image', 'email'].includes(msgContent.type) && (msgContent?.status || '') !== 'failed',
|
|
|
|
|
// 用forwarded表示Resend, 与Reply互斥
|
|
|
|
|
forwarded: msg.msg_direction === 'outbound'
|
|
|
|
|
&& msg.msg_source === 'email'
|
|
|
|
|
&& ['email'].includes(msgContent.type)
|
|
|
|
|
&& (msgContent?.status || 'failed') === 'failed',
|
|
|
|
|
forwarded: msg.msg_direction === 'outbound' && msg.msg_source === 'email' && ['email'].includes(msgContent.type) && (msgContent?.status || 'failed') === 'failed',
|
|
|
|
|
...(msg.msg_direction === 'outbound'
|
|
|
|
|
? {
|
|
|
|
|
sender: 'me',
|
|
|
|
@ -704,7 +702,7 @@ export const parseRenderMessageList = (messages) => {
|
|
|
|
|
? whatsappMsgTypeMapped[messageorigin?.type || 'unsupported'].renderForReply(messageorigin)
|
|
|
|
|
: {}),
|
|
|
|
|
// titleColor: messageorigin?.customerProfile?.name ? '#a791ff' : '#128c7e',
|
|
|
|
|
titleColor: msg.messageorigin_direction === 'inbound' ? '#a791ff' : "#128c7e",
|
|
|
|
|
titleColor: msg.messageorigin_direction === 'inbound' ? '#a791ff' : '#128c7e',
|
|
|
|
|
id: msgContent.context?.id || msgContent.context?.message_id || msgContent.reaction?.message_id || messageorigin?.wamid,
|
|
|
|
|
},
|
|
|
|
|
origin: messageorigin,
|
|
|
|
|