mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 20:18:08 +00:00
fix: Send attachments as multiple messages for whatsapp channel (#6428)
* fix: Send attachments as multiple messages for whatsapp channel * Review fixes * Fixes bug with whatsapp inbox check condition --------- Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com> Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
committed by
GitHub
parent
97b1b4c6f9
commit
d6baa5db85
@@ -701,18 +701,33 @@ export default {
|
|||||||
if (this.isSignatureEnabledForInbox && this.messageSignature) {
|
if (this.isSignatureEnabledForInbox && this.messageSignature) {
|
||||||
newMessage += '\n\n' + this.messageSignature;
|
newMessage += '\n\n' + this.messageSignature;
|
||||||
}
|
}
|
||||||
const messagePayload = this.getMessagePayload(newMessage);
|
|
||||||
|
|
||||||
this.clearMessage();
|
const isOnWhatsApp =
|
||||||
|
this.isATwilioWhatsAppChannel ||
|
||||||
|
this.isAWhatsAppCloudChannel ||
|
||||||
|
this.is360DialogWhatsAppChannel;
|
||||||
|
if (isOnWhatsApp && !this.isPrivate) {
|
||||||
|
this.sendMessageAsMultipleMessages(newMessage);
|
||||||
|
} else {
|
||||||
|
const messagePayload = this.getMessagePayload(newMessage);
|
||||||
|
this.sendMessage(messagePayload);
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.isPrivate) {
|
if (!this.isPrivate) {
|
||||||
this.clearEmailField();
|
this.clearEmailField();
|
||||||
}
|
}
|
||||||
this.sendMessage(messagePayload);
|
|
||||||
this.clearMessage();
|
this.clearMessage();
|
||||||
this.hideEmojiPicker();
|
this.hideEmojiPicker();
|
||||||
this.$emit('update:popoutReplyBox', false);
|
this.$emit('update:popoutReplyBox', false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
sendMessageAsMultipleMessages(message) {
|
||||||
|
const messages = this.getMessagePayloadForWhatsapp(message);
|
||||||
|
messages.forEach(messagePayload => {
|
||||||
|
this.sendMessage(messagePayload);
|
||||||
|
});
|
||||||
|
},
|
||||||
async onSendReply() {
|
async onSendReply() {
|
||||||
const undefinedVariables = getUndefinedVariablesInMessage({
|
const undefinedVariables = getUndefinedVariablesInMessage({
|
||||||
message: this.message,
|
message: this.message,
|
||||||
@@ -951,6 +966,33 @@ export default {
|
|||||||
(item, index) => itemIndex !== index
|
(item, index) => itemIndex !== index
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
getMessagePayloadForWhatsapp(message) {
|
||||||
|
const multipleMessagePayload = [];
|
||||||
|
const messagePayload = {
|
||||||
|
conversationId: this.currentChat.id,
|
||||||
|
message,
|
||||||
|
private: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
multipleMessagePayload.push(messagePayload);
|
||||||
|
|
||||||
|
if (this.attachedFiles && this.attachedFiles.length) {
|
||||||
|
this.attachedFiles.forEach(attachment => {
|
||||||
|
const attachedFile = this.globalConfig.directUploadsEnabled
|
||||||
|
? attachment.blobSignedId
|
||||||
|
: attachment.resource.file;
|
||||||
|
const attachmentPayload = {
|
||||||
|
conversationId: this.currentChat.id,
|
||||||
|
files: [attachedFile],
|
||||||
|
private: false,
|
||||||
|
message: '',
|
||||||
|
};
|
||||||
|
multipleMessagePayload.push(attachmentPayload);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return multipleMessagePayload;
|
||||||
|
},
|
||||||
getMessagePayload(message) {
|
getMessagePayload(message) {
|
||||||
const messagePayload = {
|
const messagePayload = {
|
||||||
conversationId: this.currentChat.id,
|
conversationId: this.currentChat.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user