about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-08-21 17:32:41 +0200
committerGitHub <noreply@github.com>2017-08-21 17:32:41 +0200
commit3534e115e5127f12292a84442b46ce93643c6d0d (patch)
treedbfe60842ddc837defb61a087b078cda8c207636 /app/models
parentea958cae7f6c960bdb54214c12de2083ab0e25b0 (diff)
Do not try to re-subscribe to unsubscribed accounts (#4653)
Diffstat (limited to 'app/models')
-rw-r--r--app/models/account.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/app/models/account.rb b/app/models/account.rb
index c4c168160..c3be975fb 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -91,7 +91,7 @@ class Account < ApplicationRecord
   scope :local, -> { where(domain: nil) }
   scope :without_followers, -> { where(followers_count: 0) }
   scope :with_followers, -> { where('followers_count > 0') }
-  scope :expiring, ->(time) { where(subscription_expires_at: nil).or(where('subscription_expires_at < ?', time)).remote.with_followers }
+  scope :expiring, ->(time) { remote.where.not(subscription_expires_at: nil).where('subscription_expires_at < ?', time) }
   scope :partitioned, -> { order('row_number() over (partition by domain)') }
   scope :silenced, -> { where(silenced: true) }
   scope :suspended, -> { where(suspended: true) }
@@ -134,11 +134,11 @@ class Account < ApplicationRecord
   end
 
   def keypair
-    OpenSSL::PKey::RSA.new(private_key || public_key)
+    @keypair ||= OpenSSL::PKey::RSA.new(private_key || public_key)
   end
 
   def subscription(webhook_url)
-    OStatus2::Subscription.new(remote_url, secret: secret, lease_seconds: 30.days.seconds, webhook: webhook_url, hub: hub_url)
+    @subscription ||= OStatus2::Subscription.new(remote_url, secret: secret, webhook: webhook_url, hub: hub_url)
   end
 
   def save_with_optional_media!