diff --git a/app/jobs/regular/confirm_sns_subscription.rb b/app/jobs/regular/confirm_sns_subscription.rb index 8019ea63c50..f4815dfb1a2 100644 --- a/app/jobs/regular/confirm_sns_subscription.rb +++ b/app/jobs/regular/confirm_sns_subscription.rb @@ -1,5 +1,3 @@ -require "aws-sdk-sns" - module Jobs class ConfirmSnsSubscription < Jobs::Base @@ -8,8 +6,9 @@ module Jobs def execute(args) return unless raw = args[:raw].presence return unless json = args[:json].presence - return unless subscribe_url = json["SubscribeURL"].presence + + require "aws-sdk-sns" return unless Aws::SNS::MessageVerifier.new.authentic?(raw) # confirm subscription by visiting the URL diff --git a/app/jobs/regular/process_sns_notification.rb b/app/jobs/regular/process_sns_notification.rb index feb65b69a0b..7a3eadbb34a 100644 --- a/app/jobs/regular/process_sns_notification.rb +++ b/app/jobs/regular/process_sns_notification.rb @@ -1,5 +1,3 @@ -require "aws-sdk-sns" - module Jobs class ProcessSnsNotification < Jobs::Base @@ -14,6 +12,7 @@ module Jobs return unless message_id = message.dig("mail", "messageId").presence return unless bounce_type = message.dig("bounce", "bounceType").presence + require "aws-sdk-sns" return unless Aws::SNS::MessageVerifier.new.authentic?(raw) message.dig("bounce", "bouncedRecipients").each do |r|