2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-02-13 15:26:40 -05:00
|
|
|
module Jobs
|
|
|
|
|
2019-10-02 00:01:53 -04:00
|
|
|
class ConfirmSnsSubscription < ::Jobs::Base
|
2019-02-13 15:26:40 -05:00
|
|
|
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
|