PERF: only require aws-sdk-sns gem when it's being used

This commit is contained in:
Régis Hanol 2019-02-14 11:08:21 +01:00
parent a3e9b809b2
commit fc14847c14
2 changed files with 3 additions and 5 deletions

View File

@ -1,5 +1,3 @@
require "aws-sdk-sns"
module Jobs module Jobs
class ConfirmSnsSubscription < Jobs::Base class ConfirmSnsSubscription < Jobs::Base
@ -8,8 +6,9 @@ module Jobs
def execute(args) def execute(args)
return unless raw = args[:raw].presence return unless raw = args[:raw].presence
return unless json = args[:json].presence return unless json = args[:json].presence
return unless subscribe_url = json["SubscribeURL"].presence return unless subscribe_url = json["SubscribeURL"].presence
require "aws-sdk-sns"
return unless Aws::SNS::MessageVerifier.new.authentic?(raw) return unless Aws::SNS::MessageVerifier.new.authentic?(raw)
# confirm subscription by visiting the URL # confirm subscription by visiting the URL

View File

@ -1,5 +1,3 @@
require "aws-sdk-sns"
module Jobs module Jobs
class ProcessSnsNotification < Jobs::Base class ProcessSnsNotification < Jobs::Base
@ -14,6 +12,7 @@ module Jobs
return unless message_id = message.dig("mail", "messageId").presence return unless message_id = message.dig("mail", "messageId").presence
return unless bounce_type = message.dig("bounce", "bounceType").presence return unless bounce_type = message.dig("bounce", "bounceType").presence
require "aws-sdk-sns"
return unless Aws::SNS::MessageVerifier.new.authentic?(raw) return unless Aws::SNS::MessageVerifier.new.authentic?(raw)
message.dig("bounce", "bouncedRecipients").each do |r| message.dig("bounce", "bouncedRecipients").each do |r|