From 4620e331d22aad6f94fb64f51a62b2df69d5901f Mon Sep 17 00:00:00 2001 From: Lei OT Date: Thu, 7 Mar 2024 15:20:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AF=E8=AE=B0=E5=BD=95:=20?= =?UTF-8?q?=E7=B1=BB=E5=9E=8Bunsupported?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/msgUtils.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/msgUtils.js b/src/lib/msgUtils.js index ac04ebb..cf87a18 100644 --- a/src/lib/msgUtils.js +++ b/src/lib/msgUtils.js @@ -402,7 +402,7 @@ export const whatsappMsgTypeMapped = { */ export const parseRenderMessageItem = (msg) => { console.log('parseRenderMessageItem', msg); - const thisMsgType = Object.keys(receivedMsgTypeMapped).includes(msg.type) ? msg.type : 'unsupported'; + const thisMsgType = Object.keys(whatsappMsgTypeMapped).includes(msg.type) ? msg.type : 'unsupported'; return { msgOrigin: msg, date: msg?.sendTime || msg?.createTime || '', @@ -442,7 +442,7 @@ export const parseRenderMessageList = (messages, conversationid = null) => { return messages.map((msg, i) => { const msgContent = msg.msgtext_AsJOSN; msgContent.template = msg.msgtype === 'template' ? { ...msgContent.template, ...msg.template_AsJOSN } : {}; - const msgType = msgContent.type; + const msgType = Object.keys(whatsappMsgTypeMapped).includes(msgContent.type) ? msgContent.type : 'unsupported'; // const parseMethod = msgContent.bizType === 'whatsapp' ? cloneDeep(whatsappMsgTypeMapped) : {}; return { msgOrigin: msgContent, @@ -468,8 +468,8 @@ export const parseRenderMessageList = (messages, conversationid = null) => { reply: { message: msg.messageorigin_AsJOSN?.text?.body || msg.messageorigin_AsJOSN?.text, title: msg.messageorigin_AsJOSN?.customerProfile?.name || msg.messageorigin_AsJOSN?.senderName || 'me', - ...(typeof whatsappMsgTypeMapped[msg.messageorigin_AsJOSN?.type]?.renderForReply === 'function' - ? whatsappMsgTypeMapped[msg.messageorigin_AsJOSN?.type].renderForReply(msg.messageorigin_AsJOSN) + ...(typeof whatsappMsgTypeMapped[(msg.messageorigin_AsJOSN?.type || 'unsupported')]?.renderForReply === 'function' + ? whatsappMsgTypeMapped[(msg.messageorigin_AsJOSN?.type || 'unsupported')].renderForReply(msg.messageorigin_AsJOSN) : {}), // titleColor: msg.messageorigin_AsJOSN?.customerProfile?.name ? '#a791ff' : "#128c7e", titleColor: msg.messageorigin_direction === 'inbound' ? '#a791ff' : "#128c7e",