From 31e06dbcd2479cf445cd29c776320ddb10bc0fa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Tue, 19 Mar 2019 11:39:41 +0100 Subject: [PATCH] FIX: SES webhook wasn't parsing the message --- app/jobs/regular/confirm_sns_subscription.rb | 2 +- app/jobs/regular/process_sns_notification.rb | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/jobs/regular/confirm_sns_subscription.rb b/app/jobs/regular/confirm_sns_subscription.rb index f4815dfb1a2..0d489c221ed 100644 --- a/app/jobs/regular/confirm_sns_subscription.rb +++ b/app/jobs/regular/confirm_sns_subscription.rb @@ -4,7 +4,7 @@ module Jobs sidekiq_options retry: false def execute(args) - return unless raw = args[:raw].presence + return unless raw = args[:raw].presence return unless json = args[:json].presence return unless subscribe_url = json["SubscribeURL"].presence diff --git a/app/jobs/regular/process_sns_notification.rb b/app/jobs/regular/process_sns_notification.rb index 7a3eadbb34a..ab26c258d64 100644 --- a/app/jobs/regular/process_sns_notification.rb +++ b/app/jobs/regular/process_sns_notification.rb @@ -4,11 +4,17 @@ module Jobs sidekiq_options retry: false def execute(args) - return unless raw = args[:raw].presence + return unless raw = args[:raw].presence return unless json = args[:json].presence - return unless message = json["Message"].presence - return unless message["notificationType"] == "Bounce" + + message = begin + JSON.parse(message) + rescue JSON::ParserError + nil + end + + return unless message && message["notificationType"] == "Bounce" return unless message_id = message.dig("mail", "messageId").presence return unless bounce_type = message.dig("bounce", "bounceType").presence