fix: Sending Audio messages not working in Whatsapp Cloud
To send audio via Cloud API, it is unnecessary to send the caption. fixes: #5078
This commit is contained in:
parent
b38877300c
commit
9bea84e2b5
1 changed files with 5 additions and 4 deletions
|
@ -70,6 +70,10 @@ class Whatsapp::Providers::WhatsappCloudService < Whatsapp::Providers::BaseServi
|
||||||
attachment = message.attachments.first
|
attachment = message.attachments.first
|
||||||
type = %w[image audio video].include?(attachment.file_type) ? attachment.file_type : 'document'
|
type = %w[image audio video].include?(attachment.file_type) ? attachment.file_type : 'document'
|
||||||
attachment_url = attachment.download_url
|
attachment_url = attachment.download_url
|
||||||
|
type_content = {
|
||||||
|
'link': attachment_url
|
||||||
|
}
|
||||||
|
type_content['caption'] = message.content if type != 'audio'
|
||||||
response = HTTParty.post(
|
response = HTTParty.post(
|
||||||
"#{phone_id_path}/messages",
|
"#{phone_id_path}/messages",
|
||||||
headers: api_headers,
|
headers: api_headers,
|
||||||
|
@ -77,10 +81,7 @@ class Whatsapp::Providers::WhatsappCloudService < Whatsapp::Providers::BaseServi
|
||||||
messaging_product: 'whatsapp',
|
messaging_product: 'whatsapp',
|
||||||
'to' => phone_number,
|
'to' => phone_number,
|
||||||
'type' => type,
|
'type' => type,
|
||||||
type.to_s => {
|
type.to_s => type_content
|
||||||
'link': attachment_url,
|
|
||||||
'caption': message.content
|
|
||||||
}
|
|
||||||
}.to_json
|
}.to_json
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue