Merge pull request #8 from Rodribm10/fix-media-audio-v2

fix(whatsapp): adiciona método text_content ao PayloadParser e ignora…
This commit is contained in:
Rodribm10 2026-02-28 17:23:17 -03:00 committed by GitHub
commit 8d247fbee0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -105,6 +105,28 @@ class Whatsapp::Providers::Wuzapi::PayloadParser
params.dig(:event, :Info, :IsGroup) || params.dig(:event, :IsGroup)
end
def text_content
# Direct text field (some WuzAPI versions)
return params.dig(:event, :Text) if params.dig(:event, :Text).present?
msg = unwrap_ephemeral_message(params.dig(:event, :Message))
return nil unless msg.is_a?(Hash)
# Standard conversation text
return msg[:conversation] if msg[:conversation].present?
# Extended text message (links, mentions, formatting)
return msg.dig(:extendedTextMessage, :text) if msg.dig(:extendedTextMessage, :text).present?
# Media captions
%i[imageMessage videoMessage documentMessage audioMessage stickerMessage].each do |key|
caption = msg.dig(key, :caption)
return caption if caption.present?
end
nil
end
private
def webhook_event_type
@ -128,6 +150,7 @@ class Whatsapp::Providers::Wuzapi::PayloadParser
Presence
PresenceUpdate
Ack
UndecryptableMessage
]
ignorable.include?(webhook_event_type)