Fix incorrect value for feature_approval.current_user for local users (#38751)

This commit is contained in:
Claire 2026-04-20 18:00:15 +02:00 committed by GitHub
parent c0b1fbe0a9
commit ccf5c09ad3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 8 deletions

View File

@ -473,7 +473,7 @@ class Account < ApplicationRecord
end
def featureable_by?(other_account)
return discoverable? && (!locked? || followed_by?(other_account)) if local?
return discoverable? && (!locked? || followed_by?(other_account) || other_account.id == id) if local?
feature_policy_for_account(other_account).in?(%i(automatic manual))
end

View File

@ -18,7 +18,8 @@ module Account::InteractionPolicyConcern
# Returns `:automatic`, `:manual`, `:unknown`, ':missing` or `:denied`
def feature_policy_for_account(other_account)
return :denied if other_account.nil? || (local? && !discoverable?)
return :automatic if local?
return locked? && !followed_by?(other_account) && self != other_account ? :denied : :automatic if local?
# Post author is always allowed to feature themselves
return :automatic if self == other_account
return :missing if feature_approval_policy.zero?

View File

@ -97,12 +97,26 @@ RSpec.describe REST::AccountSerializer do
context 'when account is locked' do
let(:account) { Fabricate(:account, locked: true) }
it 'includes a policy that allows featuring for followers' do
expect(subject['feature_approval']).to include({
'automatic' => ['followers'],
'manual' => [],
'current_user' => 'automatic',
})
context 'when the current account does not follow the user' do
it 'includes a policy that allows featuring for followers and has "denied" for the current user' do
expect(subject['feature_approval']).to include({
'automatic' => ['followers'],
'manual' => [],
'current_user' => 'denied',
})
end
end
context 'when the current account follows the user' do
before { current_user.account.follow!(account) }
it 'includes a policy that allows featuring for followers and has "automatic" for the current user' do
expect(subject['feature_approval']).to include({
'automatic' => ['followers'],
'manual' => [],
'current_user' => 'automatic',
})
end
end
end
end