mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-10-30 18:47:51 +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:
		 Nithin David Thomas
					Nithin David Thomas
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							97b1b4c6f9
						
					
				
				
					commit
					d6baa5db85
				
			| @@ -701,18 +701,33 @@ export default { | ||||
|         if (this.isSignatureEnabledForInbox && 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) { | ||||
|           this.clearEmailField(); | ||||
|         } | ||||
|         this.sendMessage(messagePayload); | ||||
|  | ||||
|         this.clearMessage(); | ||||
|         this.hideEmojiPicker(); | ||||
|         this.$emit('update:popoutReplyBox', false); | ||||
|       } | ||||
|     }, | ||||
|     sendMessageAsMultipleMessages(message) { | ||||
|       const messages = this.getMessagePayloadForWhatsapp(message); | ||||
|       messages.forEach(messagePayload => { | ||||
|         this.sendMessage(messagePayload); | ||||
|       }); | ||||
|     }, | ||||
|     async onSendReply() { | ||||
|       const undefinedVariables = getUndefinedVariablesInMessage({ | ||||
|         message: this.message, | ||||
| @@ -951,6 +966,33 @@ export default { | ||||
|         (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) { | ||||
|       const messagePayload = { | ||||
|         conversationId: this.currentChat.id, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user