|
|
|
|
@ -15,10 +15,11 @@ export const replaceTemplateString = (str, replacements) => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const autoLinkText = (text) => {
|
|
|
|
|
let regex = /(https?:\/\/[^\s]+)/g;
|
|
|
|
|
return text;
|
|
|
|
|
// let regex = /(https?:\/\/[^\s]+)/g;
|
|
|
|
|
|
|
|
|
|
let newText = text.replace(regex, '<a href="$1" target="_blank">$1</a>');
|
|
|
|
|
return newText;
|
|
|
|
|
// let newText = text.replace(regex, '<a href="$1" target="_blank">$1</a>');
|
|
|
|
|
// return newText;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
@ -298,7 +299,7 @@ export const parseRenderMessageItem = (msg) => {
|
|
|
|
|
whatsapp_name: msg?.customerProfile?.name || '',
|
|
|
|
|
whatsapp_phone_number: msg.from,
|
|
|
|
|
whatsapp_msg_type: msg.type,
|
|
|
|
|
...((isEmpty(msg.context) && isEmpty(msg.reaction)) || msg.context.forwarded === true
|
|
|
|
|
...((isEmpty(msg.context) && isEmpty(msg.reaction)) || msg.context?.forwarded === true
|
|
|
|
|
? {}
|
|
|
|
|
: {
|
|
|
|
|
reply: {
|
|
|
|
|
@ -319,7 +320,7 @@ export const parseRenderMessageItem = (msg) => {
|
|
|
|
|
* 从数据库读取的记录
|
|
|
|
|
*/
|
|
|
|
|
export const parseRenderMessageList = (messages, conversationid = null) => {
|
|
|
|
|
return messages.map((msg) => {
|
|
|
|
|
return messages.map((msg, i) => {
|
|
|
|
|
const msgContent = msg.msgtext_AsJOSN;
|
|
|
|
|
msgContent.template = msg.msgtype === 'template' ? { ...msgContent.template, ...msg.template_AsJOSN } : {};
|
|
|
|
|
const msgType = msgContent.type;
|
|
|
|
|
@ -341,14 +342,15 @@ export const parseRenderMessageList = (messages, conversationid = null) => {
|
|
|
|
|
dateString: msgStatusRenderMapped[msgContent?.status || 'failed'] === 'failed' ? `发送失败 ${whatsappError?.[msgContent.errorCode] || msgContent.errorMessage} ❌` : '',
|
|
|
|
|
}
|
|
|
|
|
: {}),
|
|
|
|
|
...(isEmpty(msg.messageorigin_AsJOSN) && isEmpty(msgContent.context)
|
|
|
|
|
...((isEmpty(msg.messageorigin_AsJOSN) && isEmpty(msgContent.context))
|
|
|
|
|
// ...((isEmpty(msg.messageorigin_AsJOSN) || isEmpty(msgContent.context))
|
|
|
|
|
? {}
|
|
|
|
|
: {
|
|
|
|
|
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)
|
|
|
|
|
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)
|
|
|
|
|
: {}),
|
|
|
|
|
// titleColor: msg.messageorigin_AsJOSN?.customerProfile?.name ? '#a791ff' : "#128c7e",
|
|
|
|
|
titleColor: msg.messageorigin_direction === 'inbound' ? '#a791ff' : "#128c7e",
|
|
|
|
|
|