fix: update send_attachment_message to address transcoding requirement (#191)

This commit is contained in:
Gabriel Jablonski 2026-01-19 15:51:12 -03:00 committed by GitHub
parent b199c2c786
commit d94d4370b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -156,7 +156,7 @@ class Whatsapp::Providers::WhatsappCloudService < Whatsapp::Providers::BaseServi
process_response(response, message)
end
def send_attachment_message(phone_number, message) # rubocop:disable Metrics/MethodLength
def send_attachment_message(phone_number, message)
attachment = message.attachments.first
type = %w[image audio video].include?(attachment.file_type) ? attachment.file_type : 'document'
type_content = {
@ -164,7 +164,8 @@ class Whatsapp::Providers::WhatsappCloudService < Whatsapp::Providers::BaseServi
}
type_content['caption'] = message.outgoing_content unless %w[audio sticker].include?(type)
type_content['filename'] = attachment.file.filename if type == 'document'
type_content['voice'] = true if type == 'audio' && attachment.meta&.dig('is_recorded_audio')
# FIXME: This requires transcoding to opus/ogg.
# type_content['voice'] = true if type == 'audio' && attachment.meta&.dig('is_recorded_audio')
response = HTTParty.post(
"#{phone_id_path('v24.0')}/messages",
headers: api_headers,