Procházet zdrojové kódy

Do not try to re-subscribe to unsubscribed accounts (#4653)

master
Eugen Rochko před 6 roky
committed by GitHub
rodič
revize
3534e115e5
4 změnil soubory, kde provedl 5 přidání a 6 odebrání
  1. +3
    -3
      app/models/account.rb
  2. +1
    -1
      app/services/block_domain_service.rb
  3. +1
    -1
      app/services/subscribe_service.rb
  4. +0
    -1
      spec/models/account_spec.rb

+ 3
- 3
app/models/account.rb Zobrazit soubor

@@ -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!


+ 1
- 1
app/services/block_domain_service.rb Zobrazit soubor

@@ -30,7 +30,7 @@ class BlockDomainService < BaseService

def suspend_accounts!
blocked_domain_accounts.where(suspended: false).find_each do |account|
account.subscription(api_subscription_url(account.id)).unsubscribe if account.subscribed?
UnsubscribeService.new.call(account) if account.subscribed?
SuspendAccountService.new.call(account)
end
end


+ 1
- 1
app/services/subscribe_service.rb Zobrazit soubor

@@ -2,7 +2,7 @@

class SubscribeService < BaseService
def call(account)
return unless account.ostatus?
return if account.hub_url.blank?

@account = account
@account.secret = SecureRandom.hex


+ 0
- 1
spec/models/account_spec.rb Zobrazit soubor

@@ -642,7 +642,6 @@ RSpec.describe Account, type: :model do
it 'returns remote accounts with followers whose subscription expiration date is past or not given' do
local = Fabricate(:account, domain: nil)
matches = [
{ domain: 'remote', subscription_expires_at: nil },
{ domain: 'remote', subscription_expires_at: '2000-01-01T00:00:00Z' },
].map(&method(:Fabricate).curry(2).call(:account))
matches.each(&local.method(:follow!))


Načítá se…
Zrušit
Uložit