diff --git a/src/lib/msgUtils.js b/src/lib/msgUtils.js index 4017d07..557cccd 100644 --- a/src/lib/msgUtils.js +++ b/src/lib/msgUtils.js @@ -13,6 +13,13 @@ export const replaceTemplateString = (str, replacements) => { return result; } + +const autoLinkText = (text) => { + let regex = /(https?:\/\/[^\s]+)/g; + + let newText = text.replace(regex, '$1'); + return newText; +} /** * // +8618777396951 lyj @@ -37,6 +44,8 @@ export const sentMsgTypeMapped = { ...msg, actionId: msg.id, conversationid: msg.id.split('.')[0], + originText: (msg.text), + text: autoLinkText(msg.text), ...(msg.context ? { reply: { @@ -169,7 +178,7 @@ export const whatsappMsgTypeMapped = { }, text: { type: 'text', - data: (msg) => ({ id: msg.wamid, text: msg.text.body }), + data: (msg) => ({ id: msg.wamid, text: autoLinkText(msg.text.body), originText: msg.text.body }), renderForReply: (msg) => ({ id: msg.wamid, message: msg.text.body }), }, image: { diff --git a/src/views/Conversations/Components/InputComposer.jsx b/src/views/Conversations/Components/InputComposer.jsx index 35f73a7..d5af10c 100644 --- a/src/views/Conversations/Components/InputComposer.jsx +++ b/src/views/Conversations/Components/InputComposer.jsx @@ -72,7 +72,7 @@ const InputBox = () => { {referenceMsg.id && (
- {referenceMsg.senderName}{referenceMsg.text}
+ {referenceMsg.senderName}{referenceMsg.originText}