Remove collections_federation feature flag (#38508)

This commit is contained in:
David Roetzel 2026-04-01 10:55:41 +02:00 committed by GitHub
parent 14544dc4dd
commit 62479b7b0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
26 changed files with 40 additions and 51 deletions

View File

@ -5,7 +5,7 @@ class ActivityPub::Activity::Accept < ActivityPub::Activity
return accept_follow_for_relay if relay_follow? return accept_follow_for_relay if relay_follow?
return accept_follow!(follow_request_from_object) unless follow_request_from_object.nil? return accept_follow!(follow_request_from_object) unless follow_request_from_object.nil?
return accept_quote!(quote_request_from_object) unless quote_request_from_object.nil? return accept_quote!(quote_request_from_object) unless quote_request_from_object.nil?
return accept_feature_request! if Mastodon::Feature.collections_federation_enabled? && feature_request_from_object.present? return accept_feature_request! if Mastodon::Feature.collections_enabled? && feature_request_from_object.present?
case @object['type'] case @object['type']
when 'Follow' when 'Follow'

View File

@ -13,12 +13,12 @@ class ActivityPub::Activity::Add < ActivityPub::Activity
add_featured add_featured
end end
when @account.collections_url when @account.collections_url
return unless Mastodon::Feature.collections_federation_enabled? return unless Mastodon::Feature.collections_enabled?
add_collection add_collection
else else
@collection = @account.collections.find_by(uri: value_or_id(@json['target'])) @collection = @account.collections.find_by(uri: value_or_id(@json['target']))
add_collection_item if @collection && Mastodon::Feature.collections_federation_enabled? add_collection_item if @collection && Mastodon::Feature.collections_enabled?
end end
end end

View File

@ -3,7 +3,7 @@
class ActivityPub::Activity::Delete < ActivityPub::Activity class ActivityPub::Activity::Delete < ActivityPub::Activity
def perform def perform
return delete_person if @account.uri == object_uri return delete_person if @account.uri == object_uri
return delete_feature_authorization! unless !Mastodon::Feature.collections_federation_enabled? || feature_authorization_from_object.nil? return delete_feature_authorization! unless !Mastodon::Feature.collections_enabled? || feature_authorization_from_object.nil?
delete_object delete_object
end end

View File

@ -4,7 +4,7 @@ class ActivityPub::Activity::FeatureRequest < ActivityPub::Activity
include Payloadable include Payloadable
def perform def perform
return unless Mastodon::Feature.collections_federation_enabled? return unless Mastodon::Feature.collections_enabled?
return if non_matching_uri_hosts?(@account.uri, @json['id']) return if non_matching_uri_hosts?(@account.uri, @json['id'])
@collection = find_or_fetch_collection @collection = find_or_fetch_collection

View File

@ -13,7 +13,7 @@ class ActivityPub::Activity::Update < ActivityPub::Activity
update_account update_account
elsif supported_object_type? || converted_object_type? elsif supported_object_type? || converted_object_type?
update_status update_status
elsif equals_or_includes_any?(@object['type'], ['FeaturedCollection']) && Mastodon::Feature.collections_federation_enabled? elsif equals_or_includes_any?(@object['type'], ['FeaturedCollection']) && Mastodon::Feature.collections_enabled?
update_collection update_collection
end end
end end

View File

@ -474,7 +474,6 @@ class Account < ApplicationRecord
def featureable_by?(other_account) def featureable_by?(other_account)
return discoverable? if local? return discoverable? if local?
return false unless Mastodon::Feature.collections_federation_enabled?
feature_policy_for_account(other_account).in?(%i(automatic manual)) feature_policy_for_account(other_account).in?(%i(automatic manual))
end end

View File

@ -65,7 +65,7 @@ class ActivityPub::ProcessAccountService < BaseService
unless @options[:only_key] || @account.suspended? unless @options[:only_key] || @account.suspended?
check_featured_collection! if @json['featured'].present? check_featured_collection! if @json['featured'].present?
check_featured_tags_collection! if @json['featuredTags'].present? check_featured_tags_collection! if @json['featuredTags'].present?
check_featured_collections_collection! if @json['featuredCollections'].present? && Mastodon::Feature.collections_federation_enabled? check_featured_collections_collection! if @json['featuredCollections'].present? && Mastodon::Feature.collections_enabled?
check_links! if @account.fields.any?(&:requires_verification?) check_links! if @account.fields.any?(&:requires_verification?)
end end

View File

@ -11,10 +11,8 @@ class AddAccountToCollectionService
@collection_item = create_collection_item @collection_item = create_collection_item
if Mastodon::Feature.collections_federation_enabled? distribute_add_activity if @account.local?
distribute_add_activity if @account.local? distribute_feature_request_activity if @account.remote?
distribute_feature_request_activity if @account.remote?
end
@collection_item @collection_item
end end

View File

@ -9,10 +9,8 @@ class CreateCollectionService
@collection.save! @collection.save!
if Mastodon::Feature.collections_federation_enabled? distribute_add_activity
distribute_add_activity distribute_feature_request_activities
distribute_feature_request_activities
end
@collection @collection
end end

View File

@ -7,7 +7,7 @@ class DeleteCollectionItemService
if collection_item.local? if collection_item.local?
revoke ? @collection_item.revoke! : @collection_item.destroy! revoke ? @collection_item.revoke! : @collection_item.destroy!
distribute_remove_activity if Mastodon::Feature.collections_federation_enabled? distribute_remove_activity
else else
collection_item.destroy! collection_item.destroy!
end end

View File

@ -5,7 +5,7 @@ class DeleteCollectionService
@collection = collection @collection = collection
@collection.destroy! @collection.destroy!
distribute_remove_activity if Mastodon::Feature.collections_federation_enabled? distribute_remove_activity
end end
private private

View File

@ -10,7 +10,7 @@ class RevokeCollectionItemService < BaseService
@collection_item.revoke! @collection_item.revoke!
distribute_stamp_deletion! if Mastodon::Feature.collections_federation_enabled? && @collection_item.remote? distribute_stamp_deletion! if @collection_item.remote?
end end
private private

View File

@ -7,7 +7,7 @@ class UpdateCollectionService
@collection = collection @collection = collection
@collection.update!(params) @collection.update!(params)
distribute_update_activity if Mastodon::Feature.collections_federation_enabled? distribute_update_activity
end end
private private

View File

@ -172,7 +172,7 @@ RSpec.describe ActivityPub::Activity::Accept do
end end
end end
context 'with a FeatureRequest', feature: :collections_federation do context 'with a FeatureRequest', feature: :collections do
let(:collection) { Fabricate(:collection, account: recipient) } let(:collection) { Fabricate(:collection, account: recipient) }
let(:collection_item) { Fabricate(:collection_item, collection:, account: sender, state: :pending) } let(:collection_item) { Fabricate(:collection_item, collection:, account: sender, state: :pending) }
let(:object) { collection_item.activity_uri } let(:object) { collection_item.activity_uri }

View File

@ -80,7 +80,7 @@ RSpec.describe ActivityPub::Activity::Add do
end end
end end
context 'when the target is the `featuredCollections` collection', feature: :collections_federation do context 'when the target is the `featuredCollections` collection', feature: :collections do
subject { described_class.new(activity_json, account) } subject { described_class.new(activity_json, account) }
let(:account) { Fabricate(:remote_account, collections_url: 'https://example.com/actor/1/featured_collections') } let(:account) { Fabricate(:remote_account, collections_url: 'https://example.com/actor/1/featured_collections') }
@ -122,7 +122,7 @@ RSpec.describe ActivityPub::Activity::Add do
end end
end end
context 'when the target is a collection', feature: :collections_federation do context 'when the target is a collection', feature: :collections do
subject { described_class.new(activity_json, collection.account) } subject { described_class.new(activity_json, collection.account) }
let(:collection) { Fabricate(:remote_collection) } let(:collection) { Fabricate(:remote_collection) }

View File

@ -120,7 +120,7 @@ RSpec.describe ActivityPub::Activity::Delete do
end end
end end
context 'with a FeatureAuthorization', feature: :collections_federation do context 'with a FeatureAuthorization', feature: :collections do
let(:recipient) { Fabricate(:account) } let(:recipient) { Fabricate(:account) }
let(:approval_uri) { 'https://example.com/authorizations/1' } let(:approval_uri) { 'https://example.com/authorizations/1' }
let(:collection) { Fabricate(:collection, account: recipient) } let(:collection) { Fabricate(:collection, account: recipient) }

View File

@ -20,7 +20,7 @@ RSpec.describe ActivityPub::Activity::FeatureRequest do
} }
end end
describe '#perform', feature: :collections_federation do describe '#perform', feature: :collections do
subject { described_class.new(json, sender) } subject { described_class.new(json, sender) }
context 'when recipient is discoverable' do context 'when recipient is discoverable' do

View File

@ -257,7 +257,7 @@ RSpec.describe ActivityPub::Activity::Update do
end end
end end
context 'with a `FeaturedCollection` object', feature: :collections_federation do context 'with a `FeaturedCollection` object', feature: :collections do
let(:collection) { Fabricate(:remote_collection, account: sender, name: 'old name', discoverable: false) } let(:collection) { Fabricate(:remote_collection, account: sender, name: 'old name', discoverable: false) }
let(:featured_collection_json) do let(:featured_collection_json) do
{ {

View File

@ -802,23 +802,17 @@ RSpec.describe Account do
let(:discoverable) { true } let(:discoverable) { true }
let(:feature_approval_policy) { (0b10 << 16) | 0 } let(:feature_approval_policy) { (0b10 << 16) | 0 }
it 'returns `false`' do context 'when the policy allows it' do
expect(subject.featureable_by?(local_account)).to be false it 'returns `true`' do
expect(subject.featureable_by?(local_account)).to be true
end
end end
context 'when collections federation is enabled', feature: :collections_federation do context 'when the policy forbids it' do
context 'when the policy allows it' do let(:feature_approval_policy) { 0 }
it 'returns `true`' do
expect(subject.featureable_by?(local_account)).to be true
end
end
context 'when the policy forbids it' do it 'returns `false`' do
let(:feature_approval_policy) { 0 } expect(subject.featureable_by?(local_account)).to be false
it 'returns `false`' do
expect(subject.featureable_by?(local_account)).to be false
end
end end
end end
end end

View File

@ -63,7 +63,7 @@ RSpec.describe ActivityPub::ProcessAccountService do
end end
end end
context 'with collection URIs', feature: :collections_federation do context 'with collection URIs', feature: :collections do
let(:payload) do let(:payload) do
{ {
'id' => 'https://foo.test', 'id' => 'https://foo.test',

View File

@ -22,14 +22,14 @@ RSpec.describe AddAccountToCollectionService do
end end
context 'when the account is local' do context 'when the account is local' do
it 'federates an `Add` activity', feature: :collections_federation do it 'federates an `Add` activity' do
subject.call(collection, account) subject.call(collection, account)
expect(ActivityPub::AccountRawDistributionWorker).to have_enqueued_sidekiq_job expect(ActivityPub::AccountRawDistributionWorker).to have_enqueued_sidekiq_job
end end
end end
context 'when the account is remote', feature: :collections_federation do context 'when the account is remote' do
let(:account) { Fabricate(:remote_account, feature_approval_policy: (0b10 << 16)) } let(:account) { Fabricate(:remote_account, feature_approval_policy: (0b10 << 16)) }
it 'marks the item as `pending` and federates a `FeatureRequest` activity' do it 'marks the item as `pending` and federates a `FeatureRequest` activity' do

View File

@ -29,7 +29,7 @@ RSpec.describe CreateCollectionService do
expect(collection).to be_local expect(collection).to be_local
end end
it 'federates an `Add` activity', feature: :collections_federation do it 'federates an `Add` activity' do
subject.call(base_params, author) subject.call(base_params, author)
expect(ActivityPub::AccountRawDistributionWorker).to have_enqueued_sidekiq_job expect(ActivityPub::AccountRawDistributionWorker).to have_enqueued_sidekiq_job
@ -65,7 +65,7 @@ RSpec.describe CreateCollectionService do
context 'when some accounts are remote' do context 'when some accounts are remote' do
let(:accounts) { Fabricate.times(2, :remote_account, feature_approval_policy: (0b10 << 16)) } let(:accounts) { Fabricate.times(2, :remote_account, feature_approval_policy: (0b10 << 16)) }
it 'marks the new items as `pending` and federates `FeatureRequest` activities', feature: :collections_federation do it 'marks the new items as `pending` and federates `FeatureRequest` activities' do
subject.call(params, author) subject.call(params, author)
new_collection = author.collections.last new_collection = author.collections.last

View File

@ -14,7 +14,7 @@ RSpec.describe DeleteCollectionItemService do
end end
context 'when the collection is local' do context 'when the collection is local' do
it 'federates a `Remove` activity', feature: :collections_federation do it 'federates a `Remove` activity' do
subject.call(collection_item) subject.call(collection_item)
expect(ActivityPub::AccountRawDistributionWorker).to have_enqueued_sidekiq_job expect(ActivityPub::AccountRawDistributionWorker).to have_enqueued_sidekiq_job
@ -33,7 +33,7 @@ RSpec.describe DeleteCollectionItemService do
let(:collection) { Fabricate(:remote_collection) } let(:collection) { Fabricate(:remote_collection) }
let!(:collection_item) { Fabricate(:collection_item, collection:, state: :accepted) } let!(:collection_item) { Fabricate(:collection_item, collection:, state: :accepted) }
it 'destroys the collection withouth federating anything', feature: :collections_federation do it 'destroys the collection withouth federating anything' do
expect { subject.call(collection_item, revoke: true) }.to change(collection.collection_items, :count).by(-1) expect { subject.call(collection_item, revoke: true) }.to change(collection.collection_items, :count).by(-1)
expect(ActivityPub::AccountRawDistributionWorker).to_not have_enqueued_sidekiq_job expect(ActivityPub::AccountRawDistributionWorker).to_not have_enqueued_sidekiq_job

View File

@ -12,7 +12,7 @@ RSpec.describe DeleteCollectionService do
expect { subject.call(collection) }.to change(Collection, :count).by(-1) expect { subject.call(collection) }.to change(Collection, :count).by(-1)
end end
it 'federates a `Remove` activity', feature: :collections_federation do it 'federates a `Remove` activity' do
subject.call(collection) subject.call(collection)
expect(ActivityPub::AccountRawDistributionWorker).to have_enqueued_sidekiq_job expect(ActivityPub::AccountRawDistributionWorker).to have_enqueued_sidekiq_job

View File

@ -12,7 +12,7 @@ RSpec.describe RevokeCollectionItemService do
.to change { collection_item.reload.state }.from('accepted').to('revoked') .to change { collection_item.reload.state }.from('accepted').to('revoked')
end end
context 'when the collection is remote', feature: :collections_federation do context 'when the collection is remote' do
let(:account) { Fabricate(:remote_account, inbox_url: 'https://example.com/actor/1/inbox') } let(:account) { Fabricate(:remote_account, inbox_url: 'https://example.com/actor/1/inbox') }
let(:collection) { Fabricate(:remote_collection, account:) } let(:collection) { Fabricate(:remote_collection, account:) }
let(:collection_item) { Fabricate(:collection_item, collection:, uri: 'https://example.com') } let(:collection_item) { Fabricate(:collection_item, collection:, uri: 'https://example.com') }

View File

@ -16,7 +16,7 @@ RSpec.describe UpdateCollectionService do
end end
context 'when something actually changed' do context 'when something actually changed' do
it 'federates an `Update` activity', feature: :collections_federation do it 'federates an `Update` activity' do
subject.call(collection, { name: 'updated' }) subject.call(collection, { name: 'updated' })
expect(ActivityPub::AccountRawDistributionWorker).to have_enqueued_sidekiq_job expect(ActivityPub::AccountRawDistributionWorker).to have_enqueued_sidekiq_job
@ -24,7 +24,7 @@ RSpec.describe UpdateCollectionService do
end end
context 'when nothing changed' do context 'when nothing changed' do
it 'does not federate an activity', feature: :collections_federation do it 'does not federate an activity' do
subject.call(collection, { name: collection.name }) subject.call(collection, { name: collection.name })
expect(ActivityPub::AccountRawDistributionWorker).to_not have_enqueued_sidekiq_job expect(ActivityPub::AccountRawDistributionWorker).to_not have_enqueued_sidekiq_job