Merge commit '1ba579b0a181fbfff514ef32b50179d2ab1fc342' into glitch-soc/merge-upstream

Conflicts:
- `app/models/public_feed.rb`:
  Minor conflict due to glitch-soc's local-only posts.
  Adopted upstream's changes.
- `spec/models/tag_feed_spec.rb`:
  Minor conflict due to glitch-soc's local-only posts.
  Adopted upstream's changes.
This commit is contained in:
Claire committed 2025-10-23 18:33:52 +02:00
commit deed31ba8c
77 files changed
+789 -87

No files matched your search

+9 -4
View File
@@ -14,15 +14,20 @@ RSpec.describe Export do
end
describe '#to_bookmarks_csv' do
before { Fabricate.times(2, :bookmark, account: account) }
let!(:bookmark) { Fabricate(:bookmark, account: account) }
let(:export) { CSV.parse(subject.to_bookmarks_csv) }
let!(:second_bookmark) { Fabricate(:bookmark, account: account) }
let!(:bookmark_of_soft_deleted) { Fabricate(:bookmark, account: account) }
before do
bookmark_of_soft_deleted.status.discard
end
it 'returns a csv of bookmarks' do
expect(export)
.to contain_exactly(
include(/statuses/),
include(/statuses/)
[ActivityPub::TagManager.instance.uri_for(bookmark.status)],
[ActivityPub::TagManager.instance.uri_for(second_bookmark.status)]
)
end
end
+320
View File
@@ -5,6 +5,11 @@ require 'rails_helper'
RSpec.describe PublicFeed do
let(:account) { Fabricate(:account) }
before do
Setting.local_live_feed_access = 'public'
Setting.remote_live_feed_access = 'public'
end
describe '#get' do
subject { described_class.new(nil).get(20).map(&:id) }
@@ -264,5 +269,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
+311
View File
@@ -3,6 +3,11 @@
require 'rails_helper'
RSpec.describe TagFeed do
before do
Setting.local_topic_feed_access = 'public'
Setting.remote_topic_feed_access = 'public'
end
describe '#get' do
let(:account) { Fabricate(:account) }
let(:tag_cats) { Fabricate(:tag, name: 'cats') }
@@ -80,5 +85,311 @@ RSpec.describe TagFeed do
expect(results).to include(status)
end
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