fix: Disable processing events if account is suspended (#6849)

This commit is contained in:
Pranav Raj S
2023-04-07 12:01:03 -07:00
committed by GitHub
parent 040e9a732f
commit 463c09184c
2 changed files with 35 additions and 8 deletions

View File

@@ -1,10 +1,9 @@
class Webhooks::WhatsappEventsJob < ApplicationJob
queue_as :default
queue_as :low
def perform(params = {})
channel = find_channel_from_whatsapp_business_payload(params) || find_channel(params)
return if channel.blank?
return if channel.reauthorization_required?
return if channel_is_inactive?(channel)
case channel.provider
when 'whatsapp_cloud'
@@ -16,6 +15,14 @@ class Webhooks::WhatsappEventsJob < ApplicationJob
private
def channel_is_inactive?(channel)
return true if channel.blank?
return true if channel.reauthorization_required?
return true unless channel.account.active?
false
end
def find_channel(params)
return unless params[:phone_number]