* feat: implement connection update handling for Baileys * feat: add message update handling for Baileys integration * feat: implement message processing and handling for Baileys integration * fix: clear message source ID from Redis when contact is not found * fix: raise error when attachment file is not found during media handling * refactor: reorganize includes in incoming_message_baileys_service * feat: add helper methods for message handling in Baileys integration * feat: include IncomingMessageServiceHelpers in MessagesUpdate module * refactor: replace IncomingMessageServiceHelpers with BaileysHandlers::Helpers in connection_update, messages_update, and messages_upsert modules * fix: mark message as unsupported when attachment file is not found * refactor: remove unnecessary namespace for includes in IncomingMessageBaileysService * refactor: add private visibility to methods in connection_update, helpers, messages_update, and messages_upsert modules * refactor: preserve original message in handle_edited_content method * fix: attachment error handling * feat: implement conversation creation logic in set_conversation method * refactor: remove unused error handling for attachment not found in messages update and upsert * feat: update last seen timestamps in conversation on message status update * feat: log warning for unsupported message update status in Baileys service * chore: merge --------- Co-authored-by: gabrieljablonski <contact@gabrieljablonski.com>
22 lines
866 B
Ruby
22 lines
866 B
Ruby
class Whatsapp::IncomingMessageBaileysService < Whatsapp::IncomingMessageBaseService
|
|
include Whatsapp::BaileysHandlers::ConnectionUpdate
|
|
include Whatsapp::BaileysHandlers::MessagesUpsert
|
|
include Whatsapp::BaileysHandlers::MessagesUpdate
|
|
|
|
class InvalidWebhookVerifyToken < StandardError; end
|
|
|
|
def perform
|
|
raise InvalidWebhookVerifyToken if processed_params[:webhookVerifyToken] != inbox.channel.provider_config['webhook_verify_token']
|
|
return if processed_params[:event].blank? || processed_params[:data].blank?
|
|
|
|
event_prefix = processed_params[:event].gsub(/[\.-]/, '_')
|
|
method_name = "process_#{event_prefix}"
|
|
if respond_to?(method_name, true)
|
|
# TODO: Implement the methods for all expected events
|
|
send(method_name)
|
|
else
|
|
Rails.logger.warn "Baileys unsupported event: #{processed_params[:event]}"
|
|
end
|
|
end
|
|
end
|