From 9bea84e2b5dff91a6264ab0fae04632c75986b77 Mon Sep 17 00:00:00 2001 From: giquieu Date: Thu, 4 Aug 2022 13:12:40 -0300 Subject: [PATCH] fix: Sending Audio messages not working in Whatsapp Cloud To send audio via Cloud API, it is unnecessary to send the caption. fixes: #5078 --- .../whatsapp/providers/whatsapp_cloud_service.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/services/whatsapp/providers/whatsapp_cloud_service.rb b/app/services/whatsapp/providers/whatsapp_cloud_service.rb index ea8c01791..0858b28f2 100644 --- a/app/services/whatsapp/providers/whatsapp_cloud_service.rb +++ b/app/services/whatsapp/providers/whatsapp_cloud_service.rb @@ -70,6 +70,10 @@ class Whatsapp::Providers::WhatsappCloudService < Whatsapp::Providers::BaseServi attachment = message.attachments.first type = %w[image audio video].include?(attachment.file_type) ? attachment.file_type : 'document' attachment_url = attachment.download_url + type_content = { + 'link': attachment_url + } + type_content['caption'] = message.content if type != 'audio' response = HTTParty.post( "#{phone_id_path}/messages", headers: api_headers, @@ -77,10 +81,7 @@ class Whatsapp::Providers::WhatsappCloudService < Whatsapp::Providers::BaseServi messaging_product: 'whatsapp', 'to' => phone_number, 'type' => type, - type.to_s => { - 'link': attachment_url, - 'caption': message.content - } + type.to_s => type_content }.to_json )