diff --git a/src/channel/bubbleMsgUtils.js b/src/channel/bubbleMsgUtils.js index e719e83..b8bf8b3 100644 --- a/src/channel/bubbleMsgUtils.js +++ b/src/channel/bubbleMsgUtils.js @@ -1,4 +1,4 @@ -import { cloneDeep, isEmpty, olog, fixTo2Decimals, pick } from "@/utils/commons"; +import { cloneDeep, isEmpty, olog, fixTo2Decimals, pick, objectMapper } from "@/utils/commons"; import dayjs from "dayjs"; import { v4 as uuid } from "uuid"; @@ -322,6 +322,45 @@ const whatsappMsgMapped = { dateString: msgcontent.status==='failed' ? `发送失败 ${whatsappError?.[msgcontent.errorCode] || msgcontent.errorMessage || ''} ❌` : '', }), }, + 'wai.message.received': { + getMsg: (result) => { + const data1 = pick(result, ['conversationid', 'opi_sn', 'coli_sn', 'coli_id']); + return isEmpty(result?.waiMessage) ? null : { ...result.waiMessage, ...data1, messageorigin: result.messageorigin, msg_source: 'wai', ...objectMapper(result.waiMessage, { direction: 'msg_direction' }) }; + }, + contentToRender: (contentObj) => { + return parseRenderMessageItem(contentObj); + }, + contentToUpdate: () => null, + }, + 'wai.message.updated': { + getMsg: (result) => { + return isEmpty(result?.waiMessage) + ? null + : { ...result.waiMessage, conversationid: result.conversationid, messageorigin: result.messageorigin, msg_source: 'wai', ...objectMapper(result.waiMessage, { direction: 'msg_direction' }) } + }, + contentToRender: (contentObj) => { + if (contentObj?.status === 'failed') { + contentObj = { + ...contentObj, + type: 'error', + text: { body: `❌` }, // contentObj.errorMessage // Message failed to send. + id: contentObj.id, + wamid: contentObj.id, + }; + return parseRenderMessageItem(contentObj); + } + // * 仅更新消息状态, 没有输出 + return null; + }, + contentToUpdate: (msgcontent) => ({ + ...msgcontent, + ...parseRenderMessageItem(msgcontent), + id: msgcontent.wamid, + status: msgStatusRenderMapped[(msgcontent?.status || 'failed')], + sender: msgcontent.msg_direction === 'outbound' ? 'me' : (msgcontent?.customerProfile ?.name || ''), + dateString: msgcontent.status==='failed' ? `发送失败 ❌` : '', + }), + }, }; const emailMsgMapped = { 'email.inbound.received': { diff --git a/src/views/Conversations/Online/Input/InputComposer.jsx b/src/views/Conversations/Online/Input/InputComposer.jsx index a37a2dc..529ac67 100644 --- a/src/views/Conversations/Online/Input/InputComposer.jsx +++ b/src/views/Conversations/Online/Input/InputComposer.jsx @@ -20,7 +20,7 @@ const ButtonStyleClsMapped = { 'waba': 'bg-waba shadow shadow-waba-300 hover:!bg-waba-400 active:bg-waba-400 focus:bg-waba-400', 'whatsapp': 'bg-whatsapp shadow shadow-whatsapp-300 hover:!bg-whatsapp-400 active:bg-whatsapp-400 focus:bg-whatsapp-400', - 'wa': 'bg-whatsapp shadow shadow-whatsapp-300 hover:!bg-whatsapp-400 active:bg-whatsapp-400 focus:bg-whatsapp-400', + 'wai': 'bg-whatsapp shadow shadow-whatsapp-300 hover:!bg-whatsapp-400 active:bg-whatsapp-400 focus:bg-whatsapp-400', }; const InputComposer = ({ channel, currentActive }) => { @@ -374,6 +374,6 @@ const InputComposer = ({ channel, currentActive }) => { ); }; -InputComposer.propTypes = { channel: PropTypes.oneOf(['waba', 'whatsapp']) }; +InputComposer.propTypes = { channel: PropTypes.oneOf(['waba', 'wai']) }; export default InputComposer; diff --git a/src/views/Conversations/Online/ReplyWrapper.jsx b/src/views/Conversations/Online/ReplyWrapper.jsx index 4a7d1c1..032d56b 100644 --- a/src/views/Conversations/Online/ReplyWrapper.jsx +++ b/src/views/Conversations/Online/ReplyWrapper.jsx @@ -84,7 +84,7 @@ const ReplyWrapper = () => { label: mobile ? '' : 'WhatsApp', icon: , children: isPermitted(PERM_USE_WHATSAPP) ? ( - + ) : (
正在开发……敬请期待
),