iachat/app/services/whatsapp/incoming_message_zapi_service.rb
Gabriel Jablonski c234023a4a
feat(zapi): handle contact messages and ignore notifications (#124)
* chore: skip notification messages

* feat: contact card messages

* fix: notification message handling

* chore: reduce code duplication

* fix: improve contact name handling in attachment

* chore(zapi): promo banner with affiliate link (#126)

* chore(zapi): promo banner with affiliate link

* chore: remove useless comment

* chore(zapi): add note about hardcoded affiliate link

* feat: provider.event_received for raw provider events (#127)

* chore(zapi): promo banner with affiliate link

* chore: remove useless comment

* feat: provider.event_received for raw provider events

* feat: add provider_event_received handling in webhook listener

* feat(baileys): use senderLid as contact identifier (#128)

* chore(zapi): promo banner with affiliate link

* chore: remove useless comment

* feat: provider.event_received for raw provider events

* feat(baileys): use senderLid as contact identifier

* fix: simplify webhook_data method by removing unnecessary fields
2025-10-26 10:48:06 -03:00

24 lines
940 B
Ruby

class Whatsapp::IncomingMessageZapiService < Whatsapp::IncomingMessageBaseService
include Events::Types
include Whatsapp::ZapiHandlers::ConnectedCallback
include Whatsapp::ZapiHandlers::DisconnectedCallback
include Whatsapp::ZapiHandlers::ReceivedCallback
include Whatsapp::ZapiHandlers::DeliveryCallback
include Whatsapp::ZapiHandlers::MessageStatusCallback
def perform
return if processed_params[:type].blank?
Rails.configuration.dispatcher.dispatch(PROVIDER_EVENT_RECEIVED, Time.zone.now, inbox: inbox, event: processed_params[:type],
payload: processed_params)
event_prefix = processed_params[:type].underscore
method_name = "process_#{event_prefix}"
if respond_to?(method_name, true)
send(method_name)
else
Rails.logger.warn "Z-API unsupported event: #{processed_params.inspect}"
end
end
end