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