diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-07-14 23:01:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-14 23:01:20 +0200 |
commit | cd9b2ab2f70b6c1da5d0abeaa88eecdfc1b41f78 (patch) | |
tree | 318a07018a0d2467cfd888c405925b4fe8f39b38 /app/services | |
parent | de397f3bc1f1c7e632d0db0754711beb6ce04664 (diff) |
Fix #2672 - Connect signed PuSH subscription requests to instance domain (#4205)
* Fix #2672 - Connect signed PuSH subscription requests to instance domain Resolves #2739 * Fix return of locate_subscription * Fix tests
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/pubsubhubbub/subscribe_service.rb | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/app/services/pubsubhubbub/subscribe_service.rb b/app/services/pubsubhubbub/subscribe_service.rb index eeb7ab258..2dba05b12 100644 --- a/app/services/pubsubhubbub/subscribe_service.rb +++ b/app/services/pubsubhubbub/subscribe_service.rb @@ -3,13 +3,15 @@ class Pubsubhubbub::SubscribeService < BaseService URL_PATTERN = /\A#{URI.regexp(%w(http https))}\z/ - attr_reader :account, :callback, :secret, :lease_seconds + attr_reader :account, :callback, :secret, + :lease_seconds, :domain - def call(account, callback, secret, lease_seconds) + def call(account, callback, secret, lease_seconds, verified_domain = nil) @account = account @callback = Addressable::URI.parse(callback).normalize.to_s @secret = secret @lease_seconds = lease_seconds + @domain = verified_domain process_subscribe end @@ -56,6 +58,14 @@ class Pubsubhubbub::SubscribeService < BaseService end def locate_subscription - Subscription.where(account: account, callback_url: callback).first_or_create!(account: account, callback_url: callback) + subscription = Subscription.find_by(account: account, callback_url: callback) + + if subscription.nil? + subscription = Subscription.new(account: account, callback_url: callback) + end + + subscription.domain = domain + subscription.save! + subscription end end |