2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-02-14 04:26:40 +08:00
|
|
|
module Jobs
|
|
|
|
|
2019-10-02 12:01:53 +08:00
|
|
|
class ConfirmSnsSubscription < ::Jobs::Base
|
2019-02-14 04:26:40 +08:00
|
|
|
sidekiq_options retry: false
|
|
|
|
|
|
|
|
def execute(args)
|
2019-03-19 18:39:41 +08:00
|
|
|
return unless raw = args[:raw].presence
|
2019-02-14 04:26:40 +08:00
|
|
|
return unless json = args[:json].presence
|
|
|
|
return unless subscribe_url = json["SubscribeURL"].presence
|
2019-02-14 18:08:21 +08:00
|
|
|
|
|
|
|
require "aws-sdk-sns"
|
2019-02-14 04:26:40 +08:00
|
|
|
return unless Aws::SNS::MessageVerifier.new.authentic?(raw)
|
|
|
|
|
2021-10-21 05:20:52 +08:00
|
|
|
uri = begin
|
|
|
|
URI.parse(subscribe_url)
|
|
|
|
rescue URI::Error
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
Net::HTTP.get(uri)
|
2019-02-14 04:26:40 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|