Class: Bobot::WebhookController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- Bobot::WebhookController
- Defined in:
- app/controllers/bobot/webhook_controller.rb
Defined Under Namespace
Classes: BadRequestError
Constant Summary collapse
- X_HUB_SIGNATURE_MISSING_WARNING =
<<-HEREDOC.freeze The X-Hub-Signature header is not present in the request. This is expected for the first webhook requests. If it continues after some time, check your app's secret token. HEREDOC
Instance Method Summary collapse
Instance Method Details
#receive ⇒ Object
30 31 32 33 34 35 36 |
# File 'app/controllers/bobot/webhook_controller.rb', line 30 def receive check_integrity trigger(parsed_body) head :ok rescue BadRequestError => error render plain: error., status: :ok end |
#verify ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/controllers/bobot/webhook_controller.rb', line 21 def verify if params['hub.mode'.freeze] == 'subscribe' && params['hub.verify_token'.freeze] == Bobot.config.verify_token render plain: params['hub.challenge'.freeze], status: :ok else render plain: "Error wrong verify token".freeze, status: :forbidden end end |
#webhook ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/bobot/webhook_controller.rb', line 11 def webhook if request.get? verify elsif request.post? receive else head :method_not_allowed end end |