发送图片链接

dev/chat
Lei OT 2 years ago
parent daa48d4c80
commit d083784a71

@ -44,6 +44,30 @@ export const sentMsgTypeMapped = {
: {}),
}),
},
photo: {
type: 'image',
contentToSend: (msg) => ({
action: 'message',
actionId: msg.id,
renderId: msg.id,
to: msg.to,
msgtype: 'image',
msgcontent: {
image: { link: msg.data.uri },
...(msg.context ? { context: msg.context, message_origin: msg.message_origin } : {}),
},
}),
contentToRender: (msg) => ({
...msg,
actionId: msg.id,
conversationid: msg.id.split('.')[0],
...(msg.context
? {
reply: { message: msg.message_origin.text, title: msg.message_origin.senderName || 'Reference' },
}
: {}),
}),
},
whatsappTemplate: {
contentToSend: (msg) => ({ action: 'message', actionId: msg.id, renderId: msg.id, to: msg.to, msgtype: 'template', msgcontent: msg.template }),
contentToRender: (msg) => {

@ -51,6 +51,23 @@ const InputBox = () => {
dispatch(setReplyTo({}));
}
};
const handleSendImage = () => {
if (textContent.trim() !== '') {
const msgObj = {
type: 'photo',
data: { uri: textContent },
sender: 'me',
to: currentConversation.whatsapp_phone_number,
id: `${currentConversation.sn}.${uuid()}`, // Date.now().toString(16),
date: new Date(),
status: 'waiting',
...(referenceMsg.id ? { context: { message_id: referenceMsg.id }, message_origin: referenceMsg } : {}),
};
invokeSendMessage(msgObj);
setTextContent('');
dispatch(setReplyTo({}));
}
}
return (
<div>

Loading…
Cancel
Save