2021-10-05 18:05:06 +00:00
|
|
|
class Webhooks::WhatsappController < ActionController::API
|
2022-07-06 19:45:03 +00:00
|
|
|
include MetaTokenVerifyConcern
|
|
|
|
|
2021-10-05 18:05:06 +00:00
|
|
|
def process_payload
|
|
|
|
Webhooks::WhatsappEventsJob.perform_later(params.to_unsafe_hash)
|
|
|
|
head :ok
|
|
|
|
end
|
2022-07-06 19:45:03 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def valid_token?(token)
|
|
|
|
channel = Channel::Whatsapp.find_by(phone_number: params[:phone_number])
|
|
|
|
whatsapp_webhook_verify_token = channel.provider_config['webhook_verify_token'] if channel.present?
|
|
|
|
token == whatsapp_webhook_verify_token if whatsapp_webhook_verify_token.present?
|
|
|
|
end
|
2021-10-05 18:05:06 +00:00
|
|
|
end
|