fix: msg time; sender name

2.0/email-builder
Lei OT 10 months ago
parent 8f5fc6551d
commit bb968b8a36

@ -398,24 +398,24 @@ export const whatsappMsgTypeMapped = {
}, },
text: { text: {
type: 'text', type: 'text',
data: (msg) => ({ id: msg.wamid, text: autoLinkText(msg?.text?.body), originText: msg?.text?.body, title: msg?.customerProfile?.name || '' }), data: (msg) => ({ id: msg.wamid, text: autoLinkText(msg?.text?.body), originText: msg?.text?.body, title: msg?.customerProfile?.name || msg?.from || '' }),
renderForReply: (msg) => ({ id: msg.wamid, message: msg?.text?.body }), renderForReply: (msg) => ({ id: msg.wamid, message: msg?.text?.body }),
}, },
image: { image: {
type: 'photo', type: 'photo',
data: (msg) => ({ data: (msg) => ({
id: msg.wamid, id: msg.wamid,
text: msg.image.caption, text: msg.image?.caption,
onPhotoError: ({ currentTarget }) => { onPhotoError: ({ currentTarget }) => {
currentTarget.onerror = null; currentTarget.onerror = null;
currentTarget.src="https://hiana-crm.oss-accelerate.aliyuncs.com/WAMedia/afe412d4-3acf-4e79-a623-048aeb4d696a.png"; currentTarget.src="https://hiana-crm.oss-accelerate.aliyuncs.com/WAMedia/afe412d4-3acf-4e79-a623-048aeb4d696a.png";
}, },
data: { data: {
id: msg.wamid, id: msg.wamid,
uri: msg.image.link, uri: msg.image?.link,
width: 'auto', width: 'auto',
height: 200, height: 200,
alt: msg.image.caption || '', alt: msg.image?.caption || '',
status: { status: {
click: true, click: true,
loading: 0, loading: 0,
@ -426,7 +426,7 @@ export const whatsappMsgTypeMapped = {
}), }),
renderForReply: (msg) => ({ renderForReply: (msg) => ({
id: msg.wamid, id: msg.wamid,
photoURL: msg.image.link, photoURL: msg.image?.link,
width: 'auto', width: 'auto',
height: 200, height: 200,
alt: msg.image?.caption || '', alt: msg.image?.caption || '',
@ -439,7 +439,7 @@ export const whatsappMsgTypeMapped = {
id: msg.wamid, id: msg.wamid,
data: { data: {
id: msg.wamid, id: msg.wamid,
uri: msg.sticker.link, uri: msg.sticker?.link,
width: '100%', width: '100%',
height: 120, height: 120,
alt: '', alt: '',
@ -602,8 +602,7 @@ export const parseRenderMessageItem = (msg) => {
dateString: dayjs(msg?.sendTime || msg.createTime).format('MM-DD HH:mm'), dateString: dayjs(msg?.sendTime || msg.createTime).format('MM-DD HH:mm'),
from: msg.from, from: msg.from,
sender: msg.from, sender: msg.from,
senderName: msg?.customerProfile?.name || msg?.fromName || msg?.from || 'me', // msg.from, senderName: msg.msg_direction === 'inbound' ? (msg?.customerProfile?.name || msg?.fromName || msg?.from || '') : 'me',
// title: msg.customerProfile.name,
customer_name: msg?.customerProfile?.name || '', customer_name: msg?.customerProfile?.name || '',
whatsapp_name: msg?.customerProfile?.name || '', whatsapp_name: msg?.customerProfile?.name || '',
whatsapp_phone_number: isEmpty(msg?.customerProfile) ? msg.to : msg.from, whatsapp_phone_number: isEmpty(msg?.customerProfile) ? msg.to : msg.from,
@ -669,13 +668,13 @@ export const parseRenderMessageList = (messages) => {
...(whatsappMsgTypeMapped?.[msgType]?.data(msgContent) || {}), ...(whatsappMsgTypeMapped?.[msgType]?.data(msgContent) || {}),
type: msgContent.type, type: msgContent.type,
...(typeof whatsappMsgTypeMapped[msgType].type === 'function' ? whatsappMsgTypeMapped[msgType].type(msg) : { type: whatsappMsgTypeMapped[msgType].type || 'text' }), ...(typeof whatsappMsgTypeMapped[msgType].type === 'function' ? whatsappMsgTypeMapped[msgType].type(msg) : { type: whatsappMsgTypeMapped[msgType].type || 'text' }),
date: msgContent?.sendTime || msg.msgtime || '', date: msg.msgtime, // msgContent?.sendTime || msg.msgtime || '',
dateText: dayjs(msgContent?.sendTime || msg.msgtime).format('MM-DD HH:mm'), dateText: dayjs(msg.msgtime).format('MM-DD HH:mm'),
dateString: dayjs(msgContent?.sendTime || msg.msgtime).format('MM-DD HH:mm'), dateString: dayjs(msg.msgtime).format('MM-DD HH:mm'),
localDate: (msg.msgtime || '').replace('T', ' '), localDate: (msg.msgtime || '').replace('T', ' '),
from: msgContent.from, from: msgContent.from,
sender: msgContent.from, sender: msgContent.from,
senderName: msgContent?.customerProfile?.name || 'me', // msgContent.from, senderName: msg.msg_direction === 'inbound' ? (msgContent?.customerProfile?.name || msgContent.from) : 'me',
replyButton: ['text', 'document', 'image', 'email'].includes(msgContent.type) && (msgContent?.status || '') !== 'failed', replyButton: ['text', 'document', 'image', 'email'].includes(msgContent.type) && (msgContent?.status || '') !== 'failed',
// 用forwarded表示Resend, 与Reply互斥 // 用forwarded表示Resend, 与Reply互斥
forwarded: msg.msg_direction === 'outbound' forwarded: msg.msg_direction === 'outbound'

Loading…
Cancel
Save