about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/api/subscriptions_controller.rb2
-rw-r--r--app/models/account.rb4
-rw-r--r--app/services/subscribe_service.rb7
3 files changed, 5 insertions, 8 deletions
diff --git a/app/controllers/api/subscriptions_controller.rb b/app/controllers/api/subscriptions_controller.rb
index 84b88765a..04d99b828 100644
--- a/app/controllers/api/subscriptions_controller.rb
+++ b/app/controllers/api/subscriptions_controller.rb
@@ -3,7 +3,7 @@ class Api::SubscriptionsController < ApiController
   respond_to :txt
 
   def show
-    if @account.subscription(api_subscription_url(@account.id)).valid?(params['hub.topic'], params['hub.verify_token'])
+    if @account.subscription(api_subscription_url(@account.id)).valid?(params['hub.topic'])
       @account.update(subscription_expires_at: Time.now + (params['hub.lease_seconds'].to_i).seconds)
       render plain: HTMLEntities.new.encode(params['hub.challenge']), status: 200
     else
diff --git a/app/models/account.rb b/app/models/account.rb
index a7f31440f..bfb10ae51 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -66,7 +66,7 @@ class Account < ApplicationRecord
   end
 
   def subscribed?
-    !(self.secret.blank? || self.verify_token.blank?)
+    !self.subscription_expires_at.nil?
   end
 
   def favourited?(status)
@@ -82,7 +82,7 @@ class Account < ApplicationRecord
   end
 
   def subscription(webhook_url)
-    OStatus2::Subscription.new(self.remote_url, secret: self.secret, token: self.verify_token, webhook: webhook_url, hub: self.hub_url)
+    OStatus2::Subscription.new(self.remote_url, secret: self.secret, lease_seconds: 86400 * 30, webhook: webhook_url, hub: self.hub_url)
   end
 
   def ping!(atom_url, hubs)
diff --git a/app/services/subscribe_service.rb b/app/services/subscribe_service.rb
index 7ead559d5..427a5e198 100644
--- a/app/services/subscribe_service.rb
+++ b/app/services/subscribe_service.rb
@@ -1,15 +1,12 @@
 class SubscribeService < BaseService
   def call(account)
-    account.secret       = SecureRandom.hex
-    account.verify_token = SecureRandom.hex
+    account.secret = SecureRandom.hex
 
     subscription = account.subscription(api_subscription_url(account.id))
     response = subscription.subscribe
 
     unless response.successful?
-      account.secret       = ''
-      account.verify_token = ''
-
+      account.secret = ''
       Rails.logger.debug "PuSH subscription request for #{account.acct} failed: #{response.message}"
     end