FIX: FIX: Correctly parse Mandrill webhooks (#17116)

Mandrill sends webhook messages as a URL-encoded body, with the
mandrill_events property as an encoded JSON array.
This commit is contained in:
Wolftallemo 2022-12-15 16:21:07 -05:00 committed by GitHub
parent 1f6e9bd5a9
commit 983a56e3bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -49,7 +49,7 @@ class WebhooksController < ActionController::Base
end end
def mandrill def mandrill
events = params["mandrill_events"] events = JSON.parse(params["mandrill_events"])
events.each do |event| events.each do |event|
message_id = event.dig("msg", "metadata", "message_id") message_id = event.dig("msg", "metadata", "message_id")
to_address = event.dig("msg", "email") to_address = event.dig("msg", "email")

View File

@ -142,7 +142,7 @@ RSpec.describe WebhooksController do
"message_id" => message_id "message_id" => message_id
} }
} }
}] }].to_json
} }
expect(response.status).to eq(200) expect(response.status).to eq(200)