|
|
|
@ -213,6 +213,13 @@ export const msgStatusRenderMapped = {
|
|
|
|
|
'read': 'read',
|
|
|
|
|
'failed': 'failed',
|
|
|
|
|
};
|
|
|
|
|
export const msgStatusRenderMappedCN = {
|
|
|
|
|
'accepted': '[发送ing]',
|
|
|
|
|
'sent': '[已发送]',
|
|
|
|
|
'delivered': '[已送达]',
|
|
|
|
|
'read': '[已读]',
|
|
|
|
|
'failed': '❗',
|
|
|
|
|
};
|
|
|
|
|
export const receivedMsgTypeMapped = {
|
|
|
|
|
...cloneDeep(whatsappMsgMapped),
|
|
|
|
|
'message': {
|
|
|
|
@ -272,7 +279,7 @@ export const whatsappMsgTypeMapped = {
|
|
|
|
|
photoURL: msg.image.link,
|
|
|
|
|
width: '100%',
|
|
|
|
|
height: 200,
|
|
|
|
|
alt: '',
|
|
|
|
|
alt: msg.image?.caption || '',
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
sticker: {
|
|
|
|
@ -333,6 +340,10 @@ export const whatsappMsgTypeMapped = {
|
|
|
|
|
audioURL: msg.audio.link,
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
renderForReply: (msg) => ({
|
|
|
|
|
id: msg.wamid,
|
|
|
|
|
message: '[语音]',
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
// unsupported: { type: 'system', data: (msg) => ({ text: 'Message type is currently not supported.' }) },
|
|
|
|
|
unsupported: {
|
|
|
|
@ -367,6 +378,10 @@ export const whatsappMsgTypeMapped = {
|
|
|
|
|
text: msg.contacts.map((ele) => `${ele.name.formatted_name}: ${ele.phones[0].wa_id}`).join('\n'),
|
|
|
|
|
data: msg.contacts.map((ele) => ({ id: ele.phones[0].wa_id, wa_id: ele.phones[0].wa_id, name: ele.name.formatted_name })),
|
|
|
|
|
}),
|
|
|
|
|
renderForReply: (msg) => ({
|
|
|
|
|
id: msg.wamid,
|
|
|
|
|
message: '[联系人]',
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
location: {
|
|
|
|
|
type: 'location',
|
|
|
|
@ -381,6 +396,10 @@ export const whatsappMsgTypeMapped = {
|
|
|
|
|
},
|
|
|
|
|
originText: msg.location?.address || '',
|
|
|
|
|
}),
|
|
|
|
|
renderForReply: (msg) => ({
|
|
|
|
|
id: msg.wamid,
|
|
|
|
|
message: '[位置]',
|
|
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
// contact: 'contact',
|
|
|
|
|
// 'contact-card': 'contact-card',
|
|
|
|
@ -419,6 +438,8 @@ export const parseRenderMessageItem = (msg) => {
|
|
|
|
|
whatsapp_name: msg?.customerProfile?.name || '',
|
|
|
|
|
whatsapp_phone_number: msg.from,
|
|
|
|
|
whatsapp_msg_type: msg.type,
|
|
|
|
|
statusCN: msgStatusRenderMappedCN[msg?.status || 'failed'],
|
|
|
|
|
statusTitle: msgStatusRenderMappedCN[msg?.status || 'failed'],
|
|
|
|
|
...((isEmpty(msg.context) && isEmpty(msg.reaction)) || msg.context?.forwarded === true
|
|
|
|
|
? {}
|
|
|
|
|
: {
|
|
|
|
@ -451,7 +472,7 @@ export const parseRenderMessageList = (messages, conversationid = null) => {
|
|
|
|
|
type: msgContent.type,
|
|
|
|
|
...(typeof whatsappMsgTypeMapped[msgType].type === 'function' ? whatsappMsgTypeMapped[msgType].type(msg) : { type: whatsappMsgTypeMapped[msgType].type || 'text' }),
|
|
|
|
|
date: msgContent?.sendTime || msg.msgtime || '',
|
|
|
|
|
localDate: msg.msgtime || '',
|
|
|
|
|
localDate: (msg.msgtime || '').replace('T', ' '),
|
|
|
|
|
from: msgContent.from,
|
|
|
|
|
sender: msgContent.from,
|
|
|
|
|
senderName: msgContent?.customerProfile?.name || msgContent.from,
|
|
|
|
@ -461,6 +482,8 @@ export const parseRenderMessageList = (messages, conversationid = null) => {
|
|
|
|
|
senderName: 'me',
|
|
|
|
|
status: msgStatusRenderMapped[msgContent?.status || 'failed'],
|
|
|
|
|
dateString: msgStatusRenderMapped[msgContent?.status || 'failed'] === 'failed' ? `发送失败 ${whatsappError?.[msgContent.errorCode] || msgContent.errorMessage} ❌` : '',
|
|
|
|
|
statusCN: msgStatusRenderMappedCN[msgContent?.status || 'failed'],
|
|
|
|
|
statusTitle: msgStatusRenderMappedCN[msgContent?.status || 'failed'],
|
|
|
|
|
}
|
|
|
|
|
: {}),
|
|
|
|
|
...((isEmpty(msg.messageorigin_AsJOSN) && isEmpty(msgContent.context))
|
|
|
|
|