has_channel.rb 586 B

12345678910111213141516171819202122
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Whatsapp::Webhook
  3. module Concerns::HasChannel
  4. private
  5. def find_channel!(callback_url_uuid)
  6. channel = Channel.where(area: 'WhatsApp::Business', active: true).find do |c|
  7. c.options['callback_url_uuid'].to_s == callback_url_uuid.to_s
  8. end
  9. raise Whatsapp::Webhook::NoChannelError if channel.nil?
  10. channel
  11. end
  12. end
  13. class NoChannelError < StandardError
  14. def initialize
  15. super(__('The WhatsApp webhook channel could not be found.'))
  16. end
  17. end
  18. end