Temporary tweak to account background refresh (#39062)

This commit is contained in:
David Roetzel 2026-05-18 12:04:28 +02:00 committed by GitHub
parent bb94f91f86
commit db304735bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 2 deletions

View File

@ -268,7 +268,19 @@ class Account < ApplicationRecord
def needs_background_refresh?
return false if local?
last_webfingered_at.blank? || last_webfingered_at <= BACKGROUND_REFRESH_INTERVAL.ago
return true if last_webfingered_at.blank? || last_webfingered_at <= BACKGROUND_REFRESH_INTERVAL.ago
# TODO: Remove some time after 4.6
# This is temporary workaround to speed up account refreshs after
# collections have been enabled / deployed.
# Accounts will be refreshed when they lack a feature_approval_policy
# but we know from other account's on the same server that they should
# have.
return false unless feature_approval_policy.zero?
Rails.cache.fetch("feature_approval_policy_availability:#{domain}", expires_in: 30.minutes) do
Account.where(domain:).where.not(feature_approval_policy: 0).exists?
end
end
def schedule_refresh_if_stale!

View File

@ -868,7 +868,17 @@ RSpec.describe Account do
context 'when account has been updated in the last week' do
let(:last_webfingered_at) { 4.days.ago }
it { is_expected.to be false }
context 'when there is no other account from the same domain with an feature approval policy' do
it { is_expected.to be false }
end
context 'when there is another account from the same domain with a feature approval policy' do
before do
Fabricate(:remote_account, domain: account.domain, feature_approval_policy: 1)
end
it { is_expected.to be true }
end
end
end
end