Fix public timeline showing reblogs of unlisted posts

Fixes #2723
This commit is contained in:
Claire 2024-06-02 21:55:04 +02:00
parent 2a34c9a01e
commit db098af556
2 changed files with 23 additions and 1 deletions

View File

@ -24,7 +24,11 @@ class PublicFeed
scope.merge!(without_local_only_scope) unless allow_local_only?
scope.merge!(without_replies_scope) unless with_replies?
scope.merge!(without_reblogs_scope) unless with_reblogs?
if with_reblogs?
scope.merge!(with_reblogs_of_public_scope)
else
scope.merge!(without_reblogs_scope)
end
scope.merge!(local_only_scope) if local_only?
scope.merge!(remote_only_scope) if remote_only?
scope.merge!(account_filters_scope) if account?
@ -90,6 +94,10 @@ class PublicFeed
Status.without_reblogs
end
def with_reblogs_of_public_scope
Status.left_outer_joins(:reblog).where(reblog: { visibility: [nil, :public] })
end
def media_only_scope
Status.joins(:media_attachments).group(:id)
end

View File

@ -41,6 +41,20 @@ RSpec.describe PublicFeed do
expect(subject).to_not include(silenced_status.id)
end
context 'with with_reblogs option' do
subject { described_class.new(nil, with_reblogs: true).get(20).map(&:id) }
it 'lists public reblogs of public posts, but not public reblogs of unlisted posts' do
status = Fabricate(:status, visibility: :public)
boost = Fabricate(:status, reblog_of_id: status.id, visibility: :public)
unlisted_status = Fabricate(:status, visibility: :unlisted)
excluded_boost = Fabricate(:status, reblog_of_id: unlisted_status.id, visibility: :public)
expect(subject).to include(boost.id)
.and not_include(excluded_boost.id)
end
end
context 'without local_only option' do
subject { described_class.new(viewer).get(20).map(&:id) }