|
|
|
@ -278,11 +278,12 @@ const emailMsgMapped = {
|
|
|
|
|
'email.inbound.received': {
|
|
|
|
|
getMsg: (result) => {
|
|
|
|
|
console.log('email.inbound.received', result);
|
|
|
|
|
return isEmpty(result?.emailMessage) ? null : { ...result.emailMessage, conversationid: result.conversationid };
|
|
|
|
|
return isEmpty(result?.emailMessage) ? null : { ...result.emailMessage, conversationid: result.conversationid, };
|
|
|
|
|
},
|
|
|
|
|
contentToRender: (contentObj) => {
|
|
|
|
|
console.log('email.inbound.received to render', contentObj);
|
|
|
|
|
// const contentObj = result?.emailMessage || result; // debug:
|
|
|
|
|
return parseRenderMessageItem(contentObj);
|
|
|
|
|
},
|
|
|
|
|
contentToUpdate: (msgcontent) => null,
|
|
|
|
|
},
|
|
|
|
@ -290,14 +291,14 @@ const emailMsgMapped = {
|
|
|
|
|
getMsg: (result) => {
|
|
|
|
|
console.log('email.updated', result);
|
|
|
|
|
const { emailMessage } = result;
|
|
|
|
|
return isEmpty(result?.emailMessage) ? null : { ...emailMessage, conversationid: result.conversationid, type: 'email', status: emailMessage.msgstatus };
|
|
|
|
|
return isEmpty(result?.emailMessage) ? null : { ...emailMessage, conversationid: result.conversationid, };
|
|
|
|
|
},
|
|
|
|
|
contentToRender: (contentObj) => null,
|
|
|
|
|
contentToUpdate: (msgcontent) => ({
|
|
|
|
|
...msgcontent,
|
|
|
|
|
...parseRenderMessageItem({...msgcontent, type: 'email'}),
|
|
|
|
|
...parseRenderMessageItem({...msgcontent, }),
|
|
|
|
|
id: msgcontent.id,
|
|
|
|
|
status: msgStatusRenderMapped[(msgcontent?.msgstatus || 'failed')],
|
|
|
|
|
status: msgStatusRenderMapped[(msgcontent?.status || 'failed')],
|
|
|
|
|
sender: 'me',
|
|
|
|
|
dateString: msgcontent.status==='failed' ? `发送失败 ❌` : '',
|
|
|
|
|
}),
|
|
|
|
@ -554,11 +555,11 @@ export const whatsappMsgTypeMapped = {
|
|
|
|
|
},
|
|
|
|
|
email: {
|
|
|
|
|
type: 'email',
|
|
|
|
|
data: (msg) => ({ id: msg.id || msg.uid, subject: msg.email.subject, }),
|
|
|
|
|
data: (msg) => ({ id: msg.id || msg.uid, subject: msg.subject, }),
|
|
|
|
|
renderForReply: (msg) => {
|
|
|
|
|
return {
|
|
|
|
|
id: msg.id,
|
|
|
|
|
message: `[邮件] ${msg.email.subject}`,
|
|
|
|
|
message: `[邮件] ${msg.subject}`,
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
@ -653,7 +654,11 @@ export const parseRenderMessageList = (messages) => {
|
|
|
|
|
sender: msgContent.from,
|
|
|
|
|
senderName: msgContent?.customerProfile?.name || 'me', // msgContent.from,
|
|
|
|
|
replyButton: ['text', 'document', 'image', 'email'].includes(msgContent.type) && (msgContent?.status || '') !== 'failed',
|
|
|
|
|
forwarded: ['text', 'email'].includes(msgContent.type) && (msgContent?.status || 'failed') === 'failed', // 用forwarded表示Resend, 与Reply互斥 // debug: email, failed
|
|
|
|
|
// 用forwarded表示Resend, 与Reply互斥 // debug: email, failed
|
|
|
|
|
forwarded: msg.msg_direction === 'outbound'
|
|
|
|
|
&& msg.msg_source === 'email'
|
|
|
|
|
&& ['email'].includes(msgContent.type)
|
|
|
|
|
&& (msgContent?.status || 'failed') === 'failed',
|
|
|
|
|
...(msg.msg_direction === 'outbound'
|
|
|
|
|
? {
|
|
|
|
|
sender: 'me',
|
|
|
|
@ -664,19 +669,19 @@ export const parseRenderMessageList = (messages) => {
|
|
|
|
|
statusTitle: msgStatusRenderMappedCN[msgContent?.status || 'failed'],
|
|
|
|
|
}
|
|
|
|
|
: {}),
|
|
|
|
|
...((isEmpty(messageorigin) && (isEmpty(msgContent.context) || msgContent.context?.forwarded === true))
|
|
|
|
|
// ...((isEmpty(msg.context) && isEmpty(msg.reaction)) || msg.context?.forwarded === true || isEmpty(messageorigin)
|
|
|
|
|
// ...((isEmpty(messageorigin) || isEmpty(msgContent.context))
|
|
|
|
|
? {}
|
|
|
|
|
...(isEmpty(messageorigin) && (isEmpty(msgContent.context) || msgContent.context?.forwarded === true)
|
|
|
|
|
? // ...((isEmpty(msg.context) && isEmpty(msg.reaction)) || msg.context?.forwarded === true || isEmpty(messageorigin)
|
|
|
|
|
// ...((isEmpty(messageorigin) || isEmpty(msgContent.context))
|
|
|
|
|
{}
|
|
|
|
|
: {
|
|
|
|
|
reply: {
|
|
|
|
|
message: messageorigin?.text?.body || messageorigin?.text,
|
|
|
|
|
title: messageorigin?.customerProfile?.name || messageorigin?.senderName || 'me',
|
|
|
|
|
...(typeof whatsappMsgTypeMapped[(messageorigin?.type || 'unsupported')]?.renderForReply === 'function'
|
|
|
|
|
? whatsappMsgTypeMapped[(messageorigin?.type || 'unsupported')].renderForReply(messageorigin)
|
|
|
|
|
...(typeof whatsappMsgTypeMapped[messageorigin?.type || 'unsupported']?.renderForReply === 'function'
|
|
|
|
|
? whatsappMsgTypeMapped[messageorigin?.type || 'unsupported'].renderForReply(messageorigin)
|
|
|
|
|
: {}),
|
|
|
|
|
titleColor: messageorigin?.customerProfile?.name ? '#a791ff' : "#128c7e",
|
|
|
|
|
// titleColor: msg.messageorigin_direction === 'inbound' ? '#a791ff' : "#128c7e",
|
|
|
|
|
// titleColor: messageorigin?.customerProfile?.name ? '#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,
|
|
|
|
@ -684,7 +689,7 @@ export const parseRenderMessageList = (messages) => {
|
|
|
|
|
// conversationid: conversationid,
|
|
|
|
|
// title: msg.customerProfile.name,
|
|
|
|
|
whatsapp_msg_type: (msg.msg_source || 'WABA') === 'WABA' ? msgContent.type : '', // 1.0接口没有msg_source
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
export const whatsappError = {
|
|
|
|
|