|
|
@ -31,7 +31,7 @@ export const sentMsgTypeMapped = {
|
|
|
|
renderId: msg.id,
|
|
|
|
renderId: msg.id,
|
|
|
|
to: msg.to,
|
|
|
|
to: msg.to,
|
|
|
|
msgtype: 'text',
|
|
|
|
msgtype: 'text',
|
|
|
|
msgcontent: { body: msg.text, ...(msg.context ? { context: msg.context, message_origin: msg.message_origin } : {}) },
|
|
|
|
msgcontent: { body: msg.text, ...(msg.context ? { context: msg.context, message_origin: msg.message_origin.origin } : {}) },
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
contentToRender: (msg) => ({
|
|
|
|
contentToRender: (msg) => ({
|
|
|
|
...msg,
|
|
|
|
...msg,
|
|
|
@ -39,7 +39,7 @@ export const sentMsgTypeMapped = {
|
|
|
|
conversationid: msg.id.split('.')[0],
|
|
|
|
conversationid: msg.id.split('.')[0],
|
|
|
|
...(msg.context
|
|
|
|
...(msg.context
|
|
|
|
? {
|
|
|
|
? {
|
|
|
|
reply: { message: msg.message_origin.text, title: msg.message_origin.senderName || 'Reference' },
|
|
|
|
reply: { message: msg.message_origin.text, title: msg.message_origin.senderName || 'Reference', titleColor: "#53bdeb", },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
: {}),
|
|
|
|
: {}),
|
|
|
|
}),
|
|
|
|
}),
|
|
|
@ -63,7 +63,7 @@ export const sentMsgTypeMapped = {
|
|
|
|
conversationid: msg.id.split('.')[0],
|
|
|
|
conversationid: msg.id.split('.')[0],
|
|
|
|
...(msg.context
|
|
|
|
...(msg.context
|
|
|
|
? {
|
|
|
|
? {
|
|
|
|
reply: { message: msg.message_origin.text, title: msg.message_origin.senderName || 'Reference' },
|
|
|
|
reply: { message: msg.message_origin.text, title: msg.message_origin.senderName || 'Reference', titleColor: "#53bdeb", },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
: {}),
|
|
|
|
: {}),
|
|
|
|
}),
|
|
|
|
}),
|
|
|
@ -91,7 +91,7 @@ const whatsappMsgMapped = {
|
|
|
|
'whatsapp.inbound_message.received': {
|
|
|
|
'whatsapp.inbound_message.received': {
|
|
|
|
getMsg: (result) => {
|
|
|
|
getMsg: (result) => {
|
|
|
|
console.log('whatsapp.inbound_message.received', result);
|
|
|
|
console.log('whatsapp.inbound_message.received', result);
|
|
|
|
return isEmpty(result?.whatsappInboundMessage) ? null : { ...result.whatsappInboundMessage, conversationid: result.conversationid };
|
|
|
|
return isEmpty(result?.whatsappInboundMessage) ? null : { ...result.whatsappInboundMessage, conversationid: result.conversationid, messageorigin: result.messageorigin };
|
|
|
|
},
|
|
|
|
},
|
|
|
|
contentToRender: (contentObj) => {
|
|
|
|
contentToRender: (contentObj) => {
|
|
|
|
console.log('whatsapp.inbound_message.received to render', contentObj);
|
|
|
|
console.log('whatsapp.inbound_message.received to render', contentObj);
|
|
|
@ -165,6 +165,7 @@ export const whatsappMsgTypeMapped = {
|
|
|
|
text: {
|
|
|
|
text: {
|
|
|
|
type: 'text',
|
|
|
|
type: 'text',
|
|
|
|
data: (msg) => ({ id: msg.wamid, text: msg.text.body }),
|
|
|
|
data: (msg) => ({ id: msg.wamid, text: msg.text.body }),
|
|
|
|
|
|
|
|
renderForReply: (msg) => ({ id: msg.wamid, message: msg.text.body }),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
image: {
|
|
|
|
image: {
|
|
|
|
type: 'photo',
|
|
|
|
type: 'photo',
|
|
|
@ -216,7 +217,7 @@ export const whatsappMsgTypeMapped = {
|
|
|
|
unsupported: { type: 'system', data: (msg) => ({ text: 'Message type is currently not supported.' }) },
|
|
|
|
unsupported: { type: 'system', data: (msg) => ({ text: 'Message type is currently not supported.' }) },
|
|
|
|
reaction: {
|
|
|
|
reaction: {
|
|
|
|
type: 'text',
|
|
|
|
type: 'text',
|
|
|
|
data: (msg) => ({ id: msg.wamid, text: msg.reaction?.emoji || msg.reaction?.text?.body || 'Reaction', reply: { message: '{content}', title: 'React from', titleColor: '#1ba784' } }), // todo:
|
|
|
|
data: (msg) => ({ id: msg.wamid, text: msg.reaction?.emoji || '', }), // todo:
|
|
|
|
},
|
|
|
|
},
|
|
|
|
document: {
|
|
|
|
document: {
|
|
|
|
type: 'file',
|
|
|
|
type: 'file',
|
|
|
@ -257,12 +258,17 @@ export const parseRenderMessageItem = (msg) => {
|
|
|
|
whatsapp_name: msg?.customerProfile?.name || '',
|
|
|
|
whatsapp_name: msg?.customerProfile?.name || '',
|
|
|
|
whatsapp_phone_number: msg.from,
|
|
|
|
whatsapp_phone_number: msg.from,
|
|
|
|
whatsapp_msg_type: msg.type,
|
|
|
|
whatsapp_msg_type: msg.type,
|
|
|
|
...(isEmpty(msg.context)
|
|
|
|
...(isEmpty(msg.context) && isEmpty(msg.reaction)
|
|
|
|
? {}
|
|
|
|
? {}
|
|
|
|
: {
|
|
|
|
: {
|
|
|
|
reply: {
|
|
|
|
reply: {
|
|
|
|
message: `${msg.context.id}`, // todo: msg.context.text?.body || msg.context.text,
|
|
|
|
/**
|
|
|
|
title: msg?.customerProfile?.name || msg.from,
|
|
|
|
* reply: { message: msg.messageorigin, title: 'React from', titleColor: '#1ba784' }
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
...(typeof whatsappMsgTypeMapped[msg?.messageorigin?.type]?.renderForReply === 'function'
|
|
|
|
|
|
|
|
? whatsappMsgTypeMapped[msg.messageorigin.type].renderForReply(msg.messageorigin)
|
|
|
|
|
|
|
|
: {}),
|
|
|
|
|
|
|
|
title: '@', // todo: 按方向显示, 不要显示号码 // msg?.customerProfile?.name
|
|
|
|
titleColor: "#53bdeb", // "#128c7e",
|
|
|
|
titleColor: "#53bdeb", // "#128c7e",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
origin: msg.context,
|
|
|
|
origin: msg.context,
|
|
|
@ -279,6 +285,7 @@ export const parseRenderMessageList = (messages, conversationid = null) => {
|
|
|
|
const msgType = msgContent.type;
|
|
|
|
const msgType = msgContent.type;
|
|
|
|
// const parseMethod = msgContent.bizType === 'whatsapp' ? cloneDeep(whatsappMsgTypeMapped) : {};
|
|
|
|
// const parseMethod = msgContent.bizType === 'whatsapp' ? cloneDeep(whatsappMsgTypeMapped) : {};
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
|
|
|
|
origin: msgContent,
|
|
|
|
...(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' }),
|
|
|
|