2
0

Add disabled setting for live and topic feeds, as well as user permission to bypass that (#36563)

This commit is contained in:
Claire
2025-10-23 10:37:05 +02:00
committed by GitHub
parent 9f7075a0ce
commit 7774cd6670
9 changed files with 677 additions and 3 deletions

View File

@@ -202,5 +202,320 @@ RSpec.describe PublicFeed do
end
end
end
context 'when both local_live_feed_access and remote_live_feed_access are disabled' do
before do
Setting.local_live_feed_access = 'disabled'
Setting.remote_live_feed_access = 'disabled'
end
context 'without local_only option' do
subject { described_class.new(viewer).get(20).map(&:id) }
let(:viewer) { nil }
let!(:local_account) { Fabricate(:account, domain: nil) }
let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
let!(:local_status) { Fabricate(:status, account: local_account) }
let!(:remote_status) { Fabricate(:status, account: remote_account) }
context 'without a viewer' do
let(:viewer) { nil }
it 'returns an empty list' do
expect(subject).to be_empty
end
end
context 'with a viewer' do
let(:viewer) { Fabricate(:account, username: 'viewer') }
it 'returns an empty list' do
expect(subject).to be_empty
end
end
context 'with a moderator as viewer' do
let(:viewer) { Fabricate(:moderator_user).account }
it 'includes all expected statuses' do
expect(subject).to include(local_status.id)
expect(subject).to include(remote_status.id)
end
end
end
context 'with a local_only option set' do
subject { described_class.new(viewer, local: true).get(20).map(&:id) }
let!(:local_account) { Fabricate(:account, domain: nil) }
let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
let!(:local_status) { Fabricate(:status, account: local_account) }
let!(:remote_status) { Fabricate(:status, account: remote_account) }
context 'without a viewer' do
let(:viewer) { nil }
it 'returns an empty list' do
expect(subject).to be_empty
end
end
context 'with a viewer' do
let(:viewer) { Fabricate(:account, username: 'viewer') }
it 'returns an empty list' do
expect(subject).to be_empty
end
end
context 'with a moderator as viewer' do
let(:viewer) { Fabricate(:moderator_user).account }
it 'does not include remote instances statuses' do
expect(subject).to include(local_status.id)
expect(subject).to_not include(remote_status.id)
end
end
end
context 'with a remote_only option set' do
subject { described_class.new(viewer, remote: true).get(20).map(&:id) }
let!(:local_account) { Fabricate(:account, domain: nil) }
let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
let!(:local_status) { Fabricate(:status, account: local_account) }
let!(:remote_status) { Fabricate(:status, account: remote_account) }
context 'without a viewer' do
let(:viewer) { nil }
it 'returns an empty list' do
expect(subject).to be_empty
end
end
context 'with a viewer' do
let(:viewer) { Fabricate(:account, username: 'viewer') }
it 'returns an empty list' do
expect(subject).to be_empty
end
end
context 'with a moderator as viewer' do
let(:viewer) { Fabricate(:moderator_user).account }
it 'includes remote statuses only' do
expect(subject).to_not include(local_status.id)
expect(subject).to include(remote_status.id)
end
end
end
end
context 'when local_live_feed_access is disabled' do
before do
Setting.local_live_feed_access = 'disabled'
end
context 'without local_only option' do
subject { described_class.new(viewer).get(20).map(&:id) }
let(:viewer) { nil }
let!(:local_account) { Fabricate(:account, domain: nil) }
let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
let!(:local_status) { Fabricate(:status, account: local_account) }
let!(:remote_status) { Fabricate(:status, account: remote_account) }
context 'without a viewer' do
let(:viewer) { nil }
it 'does not include local instances statuses' do
expect(subject).to_not include(local_status.id)
expect(subject).to include(remote_status.id)
end
end
context 'with a viewer' do
let(:viewer) { Fabricate(:account, username: 'viewer') }
it 'does not include local instances statuses' do
expect(subject).to_not include(local_status.id)
expect(subject).to include(remote_status.id)
end
end
end
context 'with a local_only option set' do
subject { described_class.new(viewer, local: true).get(20).map(&:id) }
let!(:local_account) { Fabricate(:account, domain: nil) }
let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
let!(:local_status) { Fabricate(:status, account: local_account) }
let!(:remote_status) { Fabricate(:status, account: remote_account) }
context 'without a viewer' do
let(:viewer) { nil }
it 'returns an empty list' do
expect(subject).to be_empty
end
end
context 'with a viewer' do
let(:viewer) { Fabricate(:account, username: 'viewer') }
it 'returns an empty list' do
expect(subject).to be_empty
end
end
context 'with a moderator as viewer' do
let(:viewer) { Fabricate(:moderator_user).account }
it 'does not include remote instances statuses' do
expect(subject).to include(local_status.id)
expect(subject).to_not include(remote_status.id)
end
end
end
context 'with a remote_only option set' do
subject { described_class.new(viewer, remote: true).get(20).map(&:id) }
let!(:local_account) { Fabricate(:account, domain: nil) }
let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
let!(:local_status) { Fabricate(:status, account: local_account) }
let!(:remote_status) { Fabricate(:status, account: remote_account) }
context 'without a viewer' do
let(:viewer) { nil }
it 'does not include local instances statuses' do
expect(subject).to_not include(local_status.id)
expect(subject).to include(remote_status.id)
end
end
context 'with a viewer' do
let(:viewer) { Fabricate(:account, username: 'viewer') }
it 'does not include local instances statuses' do
expect(subject).to_not include(local_status.id)
expect(subject).to include(remote_status.id)
end
end
end
end
context 'when remote_live_feed_access is disabled' do
before do
Setting.remote_live_feed_access = 'disabled'
end
context 'without local_only option' do
subject { described_class.new(viewer).get(20).map(&:id) }
let(:viewer) { nil }
let!(:local_account) { Fabricate(:account, domain: nil) }
let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
let!(:local_status) { Fabricate(:status, account: local_account) }
let!(:remote_status) { Fabricate(:status, account: remote_account) }
context 'without a viewer' do
let(:viewer) { nil }
it 'does not include remote instances statuses' do
expect(subject).to include(local_status.id)
expect(subject).to_not include(remote_status.id)
end
end
context 'with a viewer' do
let(:viewer) { Fabricate(:account, username: 'viewer') }
it 'does not include remote instances statuses' do
expect(subject).to include(local_status.id)
expect(subject).to_not include(remote_status.id)
end
it 'is not affected by personal domain blocks' do
viewer.block_domain!('test.com')
expect(subject).to include(local_status.id)
expect(subject).to_not include(remote_status.id)
end
end
end
context 'with a local_only option set' do
subject { described_class.new(viewer, local: true).get(20).map(&:id) }
let!(:local_account) { Fabricate(:account, domain: nil) }
let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
let!(:local_status) { Fabricate(:status, account: local_account) }
let!(:remote_status) { Fabricate(:status, account: remote_account) }
context 'without a viewer' do
let(:viewer) { nil }
it 'does not include remote instances statuses' do
expect(subject).to include(local_status.id)
expect(subject).to_not include(remote_status.id)
end
end
context 'with a viewer' do
let(:viewer) { Fabricate(:account, username: 'viewer') }
it 'does not include remote instances statuses' do
expect(subject).to include(local_status.id)
expect(subject).to_not include(remote_status.id)
end
it 'is not affected by personal domain blocks' do
viewer.block_domain!('test.com')
expect(subject).to include(local_status.id)
expect(subject).to_not include(remote_status.id)
end
end
end
context 'with a remote_only option set' do
subject { described_class.new(viewer, remote: true).get(20).map(&:id) }
let!(:local_account) { Fabricate(:account, domain: nil) }
let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
let!(:local_status) { Fabricate(:status, account: local_account) }
let!(:remote_status) { Fabricate(:status, account: remote_account) }
context 'without a viewer' do
let(:viewer) { nil }
it 'returns an empty list' do
expect(subject).to be_empty
end
end
context 'with a viewer' do
let(:viewer) { Fabricate(:account, username: 'viewer') }
it 'returns an empty list' do
expect(subject).to be_empty
end
end
context 'with a moderator as viewer' do
let(:viewer) { Fabricate(:moderator_user).account }
it 'does not include local instances statuses' do
expect(subject).to_not include(local_status.id)
expect(subject).to include(remote_status.id)
end
end
end
end
end
end

View File

@@ -66,5 +66,311 @@ RSpec.describe TagFeed do
results = described_class.new(tag_cats, nil).get(20)
expect(results).to include(status)
end
context 'when both local_topic_feed_access and remote_topic_feed_access are disabled' do
before do
Setting.local_topic_feed_access = 'disabled'
Setting.remote_topic_feed_access = 'disabled'
end
context 'without local_only option' do
subject { described_class.new(tag_cats, viewer).get(20).map(&:id) }
let(:viewer) { nil }
let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
let!(:local_status) { status_tagged_with_cats }
let!(:remote_status) { Fabricate(:status, account: remote_account, tags: [tag_cats]) }
context 'without a viewer' do
let(:viewer) { nil }
it 'returns an empty list' do
expect(subject).to be_empty
end
end
context 'with a viewer' do
let(:viewer) { Fabricate(:account, username: 'viewer') }
it 'returns an empty list' do
expect(subject).to be_empty
end
end
context 'with a moderator as viewer' do
let(:viewer) { Fabricate(:moderator_user).account }
it 'includes all expected statuses' do
expect(subject).to include(local_status.id)
expect(subject).to include(remote_status.id)
end
end
end
context 'with a local_only option set' do
subject { described_class.new(tag_cats, viewer, local: true).get(20).map(&:id) }
let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
let!(:local_status) { status_tagged_with_cats }
let!(:remote_status) { Fabricate(:status, account: remote_account, tags: [tag_cats]) }
context 'without a viewer' do
let(:viewer) { nil }
it 'returns an empty list' do
expect(subject).to be_empty
end
end
context 'with a viewer' do
let(:viewer) { Fabricate(:account, username: 'viewer') }
it 'returns an empty list' do
expect(subject).to be_empty
end
end
context 'with a moderator as viewer' do
let(:viewer) { Fabricate(:moderator_user).account }
it 'does not include remote instances statuses' do
expect(subject).to include(local_status.id)
expect(subject).to_not include(remote_status.id)
end
end
end
context 'with a remote_only option set' do
subject { described_class.new(tag_cats, viewer, remote: true).get(20).map(&:id) }
let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
let!(:local_status) { status_tagged_with_cats }
let!(:remote_status) { Fabricate(:status, account: remote_account, tags: [tag_cats]) }
context 'without a viewer' do
let(:viewer) { nil }
it 'returns an empty list' do
expect(subject).to be_empty
end
end
context 'with a viewer' do
let(:viewer) { Fabricate(:account, username: 'viewer') }
it 'returns an empty list' do
expect(subject).to be_empty
end
end
context 'with a moderator as viewer' do
let(:viewer) { Fabricate(:moderator_user).account }
it 'includes remote statuses only' do
expect(subject).to_not include(local_status.id)
expect(subject).to include(remote_status.id)
end
end
end
end
context 'when local_topic_feed_access is disabled' do
before do
Setting.local_topic_feed_access = 'disabled'
end
context 'without local_only option' do
subject { described_class.new(tag_cats, viewer).get(20).map(&:id) }
let(:viewer) { nil }
let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
let!(:local_status) { status_tagged_with_cats }
let!(:remote_status) { Fabricate(:status, account: remote_account, tags: [tag_cats]) }
context 'without a viewer' do
let(:viewer) { nil }
it 'does not include local instances statuses' do
expect(subject).to_not include(local_status.id)
expect(subject).to include(remote_status.id)
end
end
context 'with a viewer' do
let(:viewer) { Fabricate(:account, username: 'viewer') }
it 'does not include local instances statuses' do
expect(subject).to_not include(local_status.id)
expect(subject).to include(remote_status.id)
end
end
end
context 'with a local_only option set' do
subject { described_class.new(tag_cats, viewer, local: true).get(20).map(&:id) }
let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
let!(:local_status) { status_tagged_with_cats }
let!(:remote_status) { Fabricate(:status, account: remote_account, tags: [tag_cats]) }
context 'without a viewer' do
let(:viewer) { nil }
it 'returns an empty list' do
expect(subject).to be_empty
end
end
context 'with a viewer' do
let(:viewer) { Fabricate(:account, username: 'viewer') }
it 'returns an empty list' do
expect(subject).to be_empty
end
end
context 'with a moderator as viewer' do
let(:viewer) { Fabricate(:moderator_user).account }
it 'does not include remote instances statuses' do
expect(subject).to include(local_status.id)
expect(subject).to_not include(remote_status.id)
end
end
end
context 'with a remote_only option set' do
subject { described_class.new(tag_cats, viewer, remote: true).get(20).map(&:id) }
let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
let!(:local_status) { status_tagged_with_cats }
let!(:remote_status) { Fabricate(:status, account: remote_account, tags: [tag_cats]) }
context 'without a viewer' do
let(:viewer) { nil }
it 'does not include local instances statuses' do
expect(subject).to_not include(local_status.id)
expect(subject).to include(remote_status.id)
end
end
context 'with a viewer' do
let(:viewer) { Fabricate(:account, username: 'viewer') }
it 'does not include local instances statuses' do
expect(subject).to_not include(local_status.id)
expect(subject).to include(remote_status.id)
end
end
end
end
context 'when remote_topic_feed_access is disabled' do
before do
Setting.remote_topic_feed_access = 'disabled'
end
context 'without local_only option' do
subject { described_class.new(tag_cats, viewer).get(20).map(&:id) }
let(:viewer) { nil }
let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
let!(:local_status) { status_tagged_with_cats }
let!(:remote_status) { Fabricate(:status, account: remote_account, tags: [tag_cats]) }
context 'without a viewer' do
let(:viewer) { nil }
it 'does not include remote instances statuses' do
expect(subject).to include(local_status.id)
expect(subject).to_not include(remote_status.id)
end
end
context 'with a viewer' do
let(:viewer) { Fabricate(:account, username: 'viewer') }
it 'does not include remote instances statuses' do
expect(subject).to include(local_status.id)
expect(subject).to_not include(remote_status.id)
end
it 'is not affected by personal domain blocks' do
viewer.block_domain!('test.com')
expect(subject).to include(local_status.id)
expect(subject).to_not include(remote_status.id)
end
end
end
context 'with a local_only option set' do
subject { described_class.new(tag_cats, viewer, local: true).get(20).map(&:id) }
let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
let!(:local_status) { status_tagged_with_cats }
let!(:remote_status) { Fabricate(:status, account: remote_account, tags: [tag_cats]) }
context 'without a viewer' do
let(:viewer) { nil }
it 'does not include remote instances statuses' do
expect(subject).to include(local_status.id)
expect(subject).to_not include(remote_status.id)
end
end
context 'with a viewer' do
let(:viewer) { Fabricate(:account, username: 'viewer') }
it 'does not include remote instances statuses' do
expect(subject).to include(local_status.id)
expect(subject).to_not include(remote_status.id)
end
it 'is not affected by personal domain blocks' do
viewer.block_domain!('test.com')
expect(subject).to include(local_status.id)
expect(subject).to_not include(remote_status.id)
end
end
end
context 'with a remote_only option set' do
subject { described_class.new(tag_cats, viewer, remote: true).get(20).map(&:id) }
let!(:remote_account) { Fabricate(:account, domain: 'test.com') }
let!(:local_status) { status_tagged_with_cats }
let!(:remote_status) { Fabricate(:status, account: remote_account, tags: [tag_cats]) }
context 'without a viewer' do
let(:viewer) { nil }
it 'returns an empty list' do
expect(subject).to be_empty
end
end
context 'with a viewer' do
let(:viewer) { Fabricate(:account, username: 'viewer') }
it 'returns an empty list' do
expect(subject).to be_empty
end
end
context 'with a moderator as viewer' do
let(:viewer) { Fabricate(:moderator_user).account }
it 'does not include local instances statuses' do
expect(subject).to_not include(local_status.id)
expect(subject).to include(remote_status.id)
end
end
end
end
end
end