A platform for community discussion. Free, open, simple.
FIX: Accept HEAD requests for mandrill webhook (#17180)
Wolftallemof590b62a3119
diff --git a/app/controllers/webhooks_controller.rb b/app/controllers/webhooks_controller.rbindex e80dd92c667..7271ac5f6b8 100644--- a/app/controllers/webhooks_controller.rb+++ b/app/controllers/webhooks_controller.rb@@ -66,6 +66,12 @@ class WebhooksController < ActionController::Basesuccessend+ def mandrill_head+ # Mandrill sends a HEAD request to validate the webhook before saving+ # Rails interprets it as a GET request+ success+ end+def postmark# see https://postmarkapp.com/developer/webhooks/bounce-webhook#bounce-webhook-data# and https://postmarkapp.com/developer/api/bounce-api#bounce-typesdiff --git a/config/routes.rb b/config/routes.rbindex 79e1e9685ac..fe4e56e8d11 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -22,6 +22,7 @@ Discourse::Application.routes.draw dopost "webhooks/mailgun" => "webhooks#mailgun"post "webhooks/mailjet" => "webhooks#mailjet"post "webhooks/mandrill" => "webhooks#mandrill"+ get "webhooks/mandrill" => "webhooks#mandrill_head"post "webhooks/postmark" => "webhooks#postmark"post "webhooks/sendgrid" => "webhooks#sendgrid"post "webhooks/sparkpost" => "webhooks#sparkpost"diff --git a/spec/requests/webhooks_controller_spec.rb b/spec/requests/webhooks_controller_spec.rbindex b1f13aff6c1..95596b7f3e9 100644--- a/spec/requests/webhooks_controller_spec.rb+++ b/spec/requests/webhooks_controller_spec.rb@@ -155,6 +155,14 @@ RSpec.describe WebhooksController doendend+ context "mandrill_head" do+ it "works" do+ head "/webhooks/mandrill.json"++ expect(response.status).to eq(200)+ end+ end+context "postmark" doit "works" douser = Fabricate(:user, email: email)