todo: 联系人点击发送消息

dev/chat
Lei OT 2 years ago
parent 7013ca56fd
commit 7002f72cbf

@ -334,7 +334,7 @@ export const whatsappMsgTypeMapped = {
}),
},
// unsupported: { type: 'system', data: (msg) => ({ text: 'Message type is currently not supported.' }) },
unsupported: { type: 'text', data: (msg) => ({ text: '[暂不支持此消息类型]' }) },
unsupported: { type: 'text', data: (msg) => ({ text: `[暂不支持此消息类型](${msg.id})` }) },
reaction: {
type: 'text',
data: (msg) => ({ id: msg.wamid, text: msg.reaction?.emoji || '' }),
@ -353,6 +353,16 @@ export const whatsappMsgTypeMapped = {
message: msg.document?.caption || msg.document?.filename || '',
}),
},
contacts: {
type: 'meetingLink',
data: (msg) => ({
id: msg.wamid,
meetingID: msg.wamid,
title: msg.contacts.length === 1 ? `联系人` : `${msg.contacts.length} 位联系人`,
text: msg.contacts.map(ele => `${ele.name.formatted_name}: ${ele.phones[0].wa_id}`).join('\n'),
data: msg.contacts.map(ele => ({ id: ele.phones[0].wa_id, wa_id: ele.phones[0].wa_id, name: ele.name.formatted_name })),
}),
},
// location: 'location',
// contact: 'contact',
// 'contact-card': 'contact-card',

@ -135,6 +135,34 @@ const MessagesList = ({ reference, ...props }) => {
replyButton: ['text', 'document', 'image'].includes(message.whatsapp_msg_type) ? true : false,
className: 'whitespace-pre-wrap',
})}
{...(message.type === 'meetingLink'
? {
actionButtons:
message.data.length === 1
? [
{
onClickButton: () => {
alert(`发消息 ${message.text}`);
},
Component: () => <div>发消息</div>,
},
]
: [
{
onClickButton: () => {
alert(`${message.text}`);
},
Component: () => <div>查看</div>, //
},
{
onClickButton: () => {
navigator.clipboard.writeText(message.text);
},
Component: () => <div>复制</div>,
},
],
}
: {})}
/>
// </Dropdown>
))}

Loading…
Cancel
Save