Class: Whatsapp::Webhook::Verification
- Inherits:
-
Object
- Object
- Whatsapp::Webhook::Verification
- Defined in:
- lib/ruby/whatsapp/webhook/verification.rb
Overview
Handles the one-time GET handshake Meta sends when a webhook callback URL is
registered in the App Dashboard: hub.mode, hub.verify_token, hub.challenge.
Source: https://developers.facebook.com/documentation/business-messaging/whatsapp/webhooks/overview
Class Method Summary collapse
-
.call(params:, verify_token: Whatsapp.configuration.verify_token) ⇒ String?
The
hub.challengevalue to echo back, ornilif the request doesn't match a subscribe handshake with the expected token.
Class Method Details
.call(params:, verify_token: Whatsapp.configuration.verify_token) ⇒ String?
Returns The hub.challenge value to echo back, or nil if the
request doesn't match a subscribe handshake with the expected token.
17 18 19 20 21 22 23 |
# File 'lib/ruby/whatsapp/webhook/verification.rb', line 17 def call(params:, verify_token: Whatsapp.configuration.verify_token) return unless params["hub.mode"] == "subscribe" return if verify_token.nil? || verify_token.empty? return unless ActiveSupport::SecurityUtils.secure_compare(params["hub.verify_token"].to_s, verify_token) params["hub.challenge"] end |