Fix boosts of local users being filtered in account timelines (#27204)

shrike
Claire 2023-10-03 12:21:42 +02:00 committed by GitHub
parent 4e55001e65
commit ceb365c419
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View File

@ -60,8 +60,12 @@ class AccountStatusesFilter
.where(reblog_of_id: nil) .where(reblog_of_id: nil)
.or( .or(
scope scope
# This is basically `Status.not_domain_blocked_by_account(current_account)`
# and `Status.not_excluded_by_account(current_account)` but on the
# `reblog` association. Unfortunately, there seem to be no clean way
# to re-use those scopes in our case.
.where(reblog: { accounts: { domain: nil } }).or(scope.where.not(reblog: { accounts: { domain: current_account.excluded_from_timeline_domains } }))
.where.not(reblog: { account_id: current_account.excluded_from_timeline_account_ids }) .where.not(reblog: { account_id: current_account.excluded_from_timeline_account_ids })
.where.not(reblog: { accounts: { domain: current_account.excluded_from_timeline_domains } })
) )
end end

View File

@ -202,7 +202,7 @@ RSpec.describe AccountStatusesFilter do
context 'when blocking a reblogged domain' do context 'when blocking a reblogged domain' do
let(:other_account) { Fabricate(:account, domain: 'example.com') } let(:other_account) { Fabricate(:account, domain: 'example.com') }
let(:reblogging_status) { Fabricate(:status, account: other_account) } let(:reblogging_status) { Fabricate(:status, account: other_account) }
let(:reblog) { Fabricate(:status, account: account, visibility: 'public', reblog: reblogging_status) } let!(:reblog) { Fabricate(:status, account: account, visibility: 'public', reblog: reblogging_status) }
before do before do
current_account.block_domain!(other_account.domain) current_account.block_domain!(other_account.domain)
@ -213,6 +213,20 @@ RSpec.describe AccountStatusesFilter do
end end
end end
context 'when blocking an unrelated domain' do
let(:other_account) { Fabricate(:account, domain: nil) }
let(:reblogging_status) { Fabricate(:status, account: other_account, visibility: 'public') }
let!(:reblog) { Fabricate(:status, account: account, visibility: 'public', reblog: reblogging_status) }
before do
current_account.block_domain!('example.com')
end
it 'returns the reblog from the non-blocked domain' do
expect(subject.results.pluck(:id)).to include(reblog.id)
end
end
context 'when muting a reblogged account' do context 'when muting a reblogged account' do
let(:reblog) { status_with_reblog!('public') } let(:reblog) { status_with_reblog!('public') }