未解析的消息, 显示为不支持

dev/chat
Lei OT 2 years ago
parent c30628681d
commit 8757d5df54

@ -334,7 +334,11 @@ export const whatsappMsgTypeMapped = {
}),
},
// unsupported: { type: 'system', data: (msg) => ({ text: 'Message type is currently not supported.' }) },
unsupported: { type: 'text', data: (msg) => ({ text: `[暂不支持此消息类型](${msg.id})` }) },
unsupported: {
type: 'text',
data: (msg) => ({ id: msg.wamid, text: `[暂不支持此消息类型](${msg.wamid})` }),
renderForReply: (msg) => ({ id: msg.wamid, text: `[Message type unsupported](${msg.wamid})` }),
},
reaction: {
type: 'text',
data: (msg) => ({ id: msg.wamid, text: msg.reaction?.emoji || '' }),
@ -359,8 +363,8 @@ export const whatsappMsgTypeMapped = {
id: msg.wamid,
meetingID: msg.wamid,
title: msg.contacts.length === 1 ? `联系人` : `${msg.contacts.length} 位联系人`,
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 })),
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 })),
}),
},
location: {
@ -398,13 +402,14 @@ export const whatsappMsgTypeMapped = {
*/
export const parseRenderMessageItem = (msg) => {
console.log('parseRenderMessageItem', msg);
const thisMsgType = Object.keys(receivedMsgTypeMapped).incluses(msg.type) ? msg.type : 'unsupported';
return {
msgOrigin: msg,
date: msg?.sendTime || msg?.createTime || '',
...(whatsappMsgTypeMapped?.[msg.type]?.data(msg) || {}),
...(whatsappMsgTypeMapped?.[thisMsgType]?.data(msg) || {}),
conversationid: msg.conversationid,
...(typeof whatsappMsgTypeMapped[msg.type].type === 'function' ? whatsappMsgTypeMapped[msg.type].type(msg) : { type: whatsappMsgTypeMapped[msg.type].type || 'text' }),
// type: whatsappMsgTypeMapped?.[msg.type]?.type || 'text',
...(typeof whatsappMsgTypeMapped[thisMsgType].type === 'function' ? whatsappMsgTypeMapped[thisMsgType].type(msg) : { type: whatsappMsgTypeMapped[thisMsgType].type || 'text' }),
// type: whatsappMsgTypeMapped?.[thisMsgType]?.type || 'text',
from: msg.from,
sender: msg.from,
senderName: msg?.customerProfile?.name || msg.from,
@ -421,8 +426,8 @@ export const parseRenderMessageItem = (msg) => {
* reply: { message: msg.messageorigin, title: 'React from', titleColor: '#1ba784' }
*/
title: msg.messageorigin?.customerProfile?.name || 'me',
...(typeof whatsappMsgTypeMapped[msg?.messageorigin?.type]?.renderForReply === 'function'
? whatsappMsgTypeMapped[msg.messageorigin.type].renderForReply(msg.messageorigin)
...(typeof whatsappMsgTypeMapped[(msg?.messageorigin?.type || 'unsupported')]?.renderForReply === 'function'
? whatsappMsgTypeMapped[(msg?.messageorigin?.type || 'unsupported')].renderForReply(msg.messageorigin)
: {}),
titleColor: msg.messageorigin?.customerProfile?.name ? '#a791ff' : "#128c7e",
},

Loading…
Cancel
Save