From 5c023c8b45c03fd4485785dba1c7b900f1126402 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Mon, 13 Jan 2025 11:10:28 +0800 Subject: [PATCH] =?UTF-8?q?perf(=E5=89=8D=E7=AB=AF):=20=E5=8F=91=E5=87=BA?= =?UTF-8?q?=E7=9A=84=E6=B6=88=E6=81=AF,=20=E6=97=A0=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E5=88=99=E6=98=BE=E7=A4=BA=E4=B8=BA`=E7=AD=89=E5=BE=85`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/channel/bubbleMsgUtils.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/channel/bubbleMsgUtils.js b/src/channel/bubbleMsgUtils.js index 4ce7cb3..e43e955 100644 --- a/src/channel/bubbleMsgUtils.js +++ b/src/channel/bubbleMsgUtils.js @@ -322,7 +322,7 @@ const whatsappMsgMapped = { ...msgcontent, ...parseRenderMessageItem(msgcontent), id: msgcontent.wamid, - status: msgStatusRenderMapped[msgcontent?.status || 'failed'], + status: msgStatusRenderMapped[msgcontent?.status || 'accepted'], sender: 'me', dateString: msgcontent.status === 'failed' ? `发送失败 ${whatsappError?.[msgcontent.errorCode] || msgcontent.errorMessage || ''} ❌` : '', }), @@ -369,7 +369,7 @@ const whatsappMsgMapped = { ...msgcontent, ...parseRenderMessageItem(msgcontent), id: msgcontent.wamid, - status: msgcontent.msg_direction === 'outbound' ? msgStatusRenderMapped[msgcontent?.status || 'failed'] : '', + status: msgcontent.msg_direction === 'outbound' ? msgStatusRenderMapped[msgcontent?.status || 'accepted'] : '', sender: msgcontent.msg_direction === 'outbound' ? 'me' : msgcontent?.customerProfile?.name || '', dateString: msgcontent.status === 'failed' ? `发送失败 ❌` : '', }), @@ -419,7 +419,7 @@ const emailMsgMapped = { ...msgcontent, ...parseRenderMessageItem({...msgcontent, }), id: msgcontent.id, - status: msgStatusRenderMapped[(msgcontent?.status || 'failed')], + status: msgStatusRenderMapped[(msgcontent?.status || 'accepted')], sender: 'me', dateString: msgcontent.status==='failed' ? `发送失败 ❌` : '', }), @@ -467,7 +467,7 @@ export const receivedMsgTypeMapped = { ...msgcontent, actionId: msgcontent.actionId, id: msgcontent.wamid, - status: msgStatusRenderMapped[(msgcontent?.status || 'failed')], + status: msgStatusRenderMapped[(msgcontent?.status || 'accepted')], conversationid: msgcontent.actionId.split('.')[0], // msgcontent.conversation.sn, date: msgcontent.createTime, sender: 'me', @@ -735,9 +735,9 @@ export const parseRenderMessageItem = (msg) => { whatsapp_phone_number: isEmpty(msg?.customerProfile) ? msg.to : msg.from, // whatsapp_msg_type: msg.msg_source==='WABA' ? msg.type : '', // whatsapp_msg_type: (msg.msg_source || 'WABA') === 'WABA' ? msg.type : '', // 1.0接口没有msg_source - statusCN: msgStatusRenderMappedCN[msg?.status || 'failed'], - statusTitle: msgStatusRenderMappedCN[msg?.status || 'failed'], - replyButton: !['waiting', 'failed'].includes(msg?.status || '') , + statusCN: msgStatusRenderMappedCN[msg?.status || 'accepted'], + statusTitle: msgStatusRenderMappedCN[msg?.status || 'accepted'], + replyButton: !['accepted', 'waiting', 'failed'].includes(msg?.status || '') , ...((isEmpty(msg.context) && isEmpty(msg.reaction)) || msg.context?.forwarded === true // || isEmpty(msg.messageorigin) ? {} : { @@ -789,7 +789,7 @@ export const parseRenderMessageList = (messages) => { msgContent.template = msg.msgtype === 'template' ? { ...msgContent.template, ...template } : {}; // const parseMethod = msgContent.bizType === 'whatsapp' ? cloneDeep(whatsappMsgTypeMapped) : {}; let waCode, waError = ''; - if ((msgContent?.status || 'failed') === 'failed' && msgContent.errorMessage && msg.msg_direction === 'outbound') { + if ((msgContent?.status || 'accepted') === 'failed' && msgContent.errorMessage && msg.msg_direction === 'outbound') { (waCode = msgContent.errorMessage.match(/\(#(\d+)\)/)); (waError = (whatsappError?.[waCode?.[1]] || whatsappError?.[msgContent.errorCode] || msgContent.errorMessage)); if (!isEmpty(msgContent.whatsappApiError)) { @@ -816,20 +816,20 @@ export const parseRenderMessageList = (messages) => { from: msgContent.from, sender: msgContent.from, senderName: msgContent?.customerProfile?.name || msgContent.from || 'me', - replyButton: !['waiting', 'failed'].includes(msgContent?.status || '') , + replyButton: !['accepted', 'waiting', 'failed'].includes(msgContent?.status || '') , // 用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 || 'accepted') === 'failed', ...(msg.msg_direction === 'outbound' ? { sender: 'me', senderName: 'me', - status: msgStatusRenderMapped[msgContent?.status || 'failed'], - dateString: msgStatusRenderMapped[msgContent?.status || 'failed'] === 'failed' ? `${(msg.msgtime || '').replace('T', ' ')} 发送失败 ${waError} ❌` : '', - statusCN: msgStatusRenderMappedCN[msgContent?.status || 'failed'], - statusTitle: msgStatusRenderMappedCN[msgContent?.status || 'failed'], - id: (msgContent?.status || 'failed') === 'failed' ? (msgContent.actionId || msgContent.id) : (msgTypeData.id || msg.id || msg.sn), + status: msgStatusRenderMapped[msgContent?.status || 'accepted'], + dateString: msgStatusRenderMapped[msgContent?.status || 'accepted'] === 'failed' ? `${(msg.msgtime || '').replace('T', ' ')} 发送失败 ${waError} ❌` : '', + statusCN: msgStatusRenderMappedCN[msgContent?.status || 'accepted'], + statusTitle: msgStatusRenderMappedCN[msgContent?.status || 'accepted'], + id: (msgContent?.status || 'accepted') === 'failed' ? (msgContent.actionId || msgContent.id) : (msgTypeData.id || msg.id || msg.sn), actionId: msgContent.actionId, - replyButton: !['waiting', 'failed'].includes(msgContent?.status || 'failed') , + replyButton: !['accepted', 'waiting', 'failed'].includes(msgContent?.status || 'accepted') , } : {}), ...(isEmpty(messageorigin) && (isEmpty(msgContent.context) || msgContent.context?.forwarded === true)