2019-02-13 15:26:40 -05:00
|
|
|
module Jobs
|
|
|
|
|
|
|
|
class ConfirmSnsSubscription < Jobs::Base
|
|
|
|
sidekiq_options retry: false
|
|
|
|
|
|
|
|
def execute(args)
|
2019-03-19 06:39:41 -04:00
|
|
|
return unless raw = args[:raw].presence
|
2019-02-13 15:26:40 -05:00
|
|
|
return unless json = args[:json].presence
|
|
|
|
return unless subscribe_url = json["SubscribeURL"].presence
|
2019-02-14 05:08:21 -05:00
|
|
|
|
|
|
|
require "aws-sdk-sns"
|
2019-02-13 15:26:40 -05:00
|
|
|
return unless Aws::SNS::MessageVerifier.new.authentic?(raw)
|
|
|
|
|
|
|
|
# confirm subscription by visiting the URL
|
|
|
|
open(subscribe_url)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|