Fix blocked domain appears from account feed (#26823)

Co-authored-by: Jeong Arm <kjwonmail@gmail.com>
Co-authored-by: Eugen Rochko <eugen@zeonfederated.com>
shrike
Claire 2023-09-06 21:04:48 +02:00 committed by GitHub
parent 14f6798836
commit 1f99d86287
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -55,7 +55,14 @@ class AccountStatusesFilter
end end
def filtered_reblogs_scope def filtered_reblogs_scope
Status.left_outer_joins(:reblog).where(reblog_of_id: nil).or(Status.where.not(reblogs_statuses: { account_id: current_account.excluded_from_timeline_account_ids })) scope = Status.left_outer_joins(reblog: :account)
scope
.where(reblog_of_id: nil)
.or(
scope
.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
def only_media_scope def only_media_scope

View File

@ -199,6 +199,20 @@ RSpec.describe AccountStatusesFilter do
end end
end end
context 'when blocking a reblogged domain' do
let(:other_account) { Fabricate(:account, domain: 'example.com') }
let(:reblogging_status) { Fabricate(:status, account: other_account) }
let(:reblog) { Fabricate(:status, account: account, visibility: 'public', reblog: reblogging_status) }
before do
current_account.block_domain!(other_account.domain)
end
it 'does not return reblog of blocked domain' do
expect(subject.results.pluck(:id)).to_not 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') }