diff --git a/app/lib/activitypub/activity/accept.rb b/app/lib/activitypub/activity/accept.rb index 91610d68cf..4dc6977b8e 100644 --- a/app/lib/activitypub/activity/accept.rb +++ b/app/lib/activitypub/activity/accept.rb @@ -5,7 +5,7 @@ class ActivityPub::Activity::Accept < ActivityPub::Activity return accept_follow_for_relay if relay_follow? 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_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'] when 'Follow' diff --git a/app/lib/activitypub/activity/add.rb b/app/lib/activitypub/activity/add.rb index cfaf29a3be..0d22910a9a 100644 --- a/app/lib/activitypub/activity/add.rb +++ b/app/lib/activitypub/activity/add.rb @@ -13,12 +13,12 @@ class ActivityPub::Activity::Add < ActivityPub::Activity add_featured end when @account.collections_url - return unless Mastodon::Feature.collections_federation_enabled? + return unless Mastodon::Feature.collections_enabled? add_collection else @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 diff --git a/app/lib/activitypub/activity/delete.rb b/app/lib/activitypub/activity/delete.rb index 62c298a638..1239462a11 100644 --- a/app/lib/activitypub/activity/delete.rb +++ b/app/lib/activitypub/activity/delete.rb @@ -3,7 +3,7 @@ class ActivityPub::Activity::Delete < ActivityPub::Activity def perform 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 end diff --git a/app/lib/activitypub/activity/feature_request.rb b/app/lib/activitypub/activity/feature_request.rb index 67355f6bda..5e319734a4 100644 --- a/app/lib/activitypub/activity/feature_request.rb +++ b/app/lib/activitypub/activity/feature_request.rb @@ -4,7 +4,7 @@ class ActivityPub::Activity::FeatureRequest < ActivityPub::Activity include Payloadable 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']) @collection = find_or_fetch_collection diff --git a/app/lib/activitypub/activity/update.rb b/app/lib/activitypub/activity/update.rb index b40e8f381b..8eb2427a84 100644 --- a/app/lib/activitypub/activity/update.rb +++ b/app/lib/activitypub/activity/update.rb @@ -13,7 +13,7 @@ class ActivityPub::Activity::Update < ActivityPub::Activity update_account elsif supported_object_type? || converted_object_type? 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 end end diff --git a/app/models/account.rb b/app/models/account.rb index 8c44db813a..141a9fb7e6 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -474,7 +474,6 @@ class Account < ApplicationRecord def featureable_by?(other_account) return discoverable? if local? - return false unless Mastodon::Feature.collections_federation_enabled? feature_policy_for_account(other_account).in?(%i(automatic manual)) end diff --git a/app/services/activitypub/process_account_service.rb b/app/services/activitypub/process_account_service.rb index 4a5597f2fe..65b1d03897 100644 --- a/app/services/activitypub/process_account_service.rb +++ b/app/services/activitypub/process_account_service.rb @@ -65,7 +65,7 @@ class ActivityPub::ProcessAccountService < BaseService unless @options[:only_key] || @account.suspended? check_featured_collection! if @json['featured'].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?) end diff --git a/app/services/add_account_to_collection_service.rb b/app/services/add_account_to_collection_service.rb index c5a4697e79..0cca1a31ff 100644 --- a/app/services/add_account_to_collection_service.rb +++ b/app/services/add_account_to_collection_service.rb @@ -11,10 +11,8 @@ class AddAccountToCollectionService @collection_item = create_collection_item - if Mastodon::Feature.collections_federation_enabled? - distribute_add_activity if @account.local? - distribute_feature_request_activity if @account.remote? - end + distribute_add_activity if @account.local? + distribute_feature_request_activity if @account.remote? @collection_item end diff --git a/app/services/create_collection_service.rb b/app/services/create_collection_service.rb index 979794224a..e38bddebba 100644 --- a/app/services/create_collection_service.rb +++ b/app/services/create_collection_service.rb @@ -9,10 +9,8 @@ class CreateCollectionService @collection.save! - if Mastodon::Feature.collections_federation_enabled? - distribute_add_activity - distribute_feature_request_activities - end + distribute_add_activity + distribute_feature_request_activities @collection end diff --git a/app/services/delete_collection_item_service.rb b/app/services/delete_collection_item_service.rb index 168eb9ba0a..3f91ea0c3b 100644 --- a/app/services/delete_collection_item_service.rb +++ b/app/services/delete_collection_item_service.rb @@ -7,7 +7,7 @@ class DeleteCollectionItemService if collection_item.local? revoke ? @collection_item.revoke! : @collection_item.destroy! - distribute_remove_activity if Mastodon::Feature.collections_federation_enabled? + distribute_remove_activity else collection_item.destroy! end diff --git a/app/services/delete_collection_service.rb b/app/services/delete_collection_service.rb index 78b9261fd1..c2cc6ebd6c 100644 --- a/app/services/delete_collection_service.rb +++ b/app/services/delete_collection_service.rb @@ -5,7 +5,7 @@ class DeleteCollectionService @collection = collection @collection.destroy! - distribute_remove_activity if Mastodon::Feature.collections_federation_enabled? + distribute_remove_activity end private diff --git a/app/services/revoke_collection_item_service.rb b/app/services/revoke_collection_item_service.rb index 9b5c53f70c..0b3c2c709e 100644 --- a/app/services/revoke_collection_item_service.rb +++ b/app/services/revoke_collection_item_service.rb @@ -10,7 +10,7 @@ class RevokeCollectionItemService < BaseService @collection_item.revoke! - distribute_stamp_deletion! if Mastodon::Feature.collections_federation_enabled? && @collection_item.remote? + distribute_stamp_deletion! if @collection_item.remote? end private diff --git a/app/services/update_collection_service.rb b/app/services/update_collection_service.rb index 9dffac9e2b..f097a8cfb8 100644 --- a/app/services/update_collection_service.rb +++ b/app/services/update_collection_service.rb @@ -7,7 +7,7 @@ class UpdateCollectionService @collection = collection @collection.update!(params) - distribute_update_activity if Mastodon::Feature.collections_federation_enabled? + distribute_update_activity end private diff --git a/spec/lib/activitypub/activity/accept_spec.rb b/spec/lib/activitypub/activity/accept_spec.rb index f7c1e1d617..732f01cc6d 100644 --- a/spec/lib/activitypub/activity/accept_spec.rb +++ b/spec/lib/activitypub/activity/accept_spec.rb @@ -172,7 +172,7 @@ RSpec.describe ActivityPub::Activity::Accept do 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_item) { Fabricate(:collection_item, collection:, account: sender, state: :pending) } let(:object) { collection_item.activity_uri } diff --git a/spec/lib/activitypub/activity/add_spec.rb b/spec/lib/activitypub/activity/add_spec.rb index d0bdfbe218..b444f38a3d 100644 --- a/spec/lib/activitypub/activity/add_spec.rb +++ b/spec/lib/activitypub/activity/add_spec.rb @@ -80,7 +80,7 @@ RSpec.describe ActivityPub::Activity::Add do 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) } 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 - 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) } let(:collection) { Fabricate(:remote_collection) } diff --git a/spec/lib/activitypub/activity/delete_spec.rb b/spec/lib/activitypub/activity/delete_spec.rb index c2b3a63431..c6d74b4b5b 100644 --- a/spec/lib/activitypub/activity/delete_spec.rb +++ b/spec/lib/activitypub/activity/delete_spec.rb @@ -120,7 +120,7 @@ RSpec.describe ActivityPub::Activity::Delete do end end - context 'with a FeatureAuthorization', feature: :collections_federation do + context 'with a FeatureAuthorization', feature: :collections do let(:recipient) { Fabricate(:account) } let(:approval_uri) { 'https://example.com/authorizations/1' } let(:collection) { Fabricate(:collection, account: recipient) } diff --git a/spec/lib/activitypub/activity/feature_request_spec.rb b/spec/lib/activitypub/activity/feature_request_spec.rb index cd199a806a..a7fc14e325 100644 --- a/spec/lib/activitypub/activity/feature_request_spec.rb +++ b/spec/lib/activitypub/activity/feature_request_spec.rb @@ -20,7 +20,7 @@ RSpec.describe ActivityPub::Activity::FeatureRequest do } end - describe '#perform', feature: :collections_federation do + describe '#perform', feature: :collections do subject { described_class.new(json, sender) } context 'when recipient is discoverable' do diff --git a/spec/lib/activitypub/activity/update_spec.rb b/spec/lib/activitypub/activity/update_spec.rb index ba69c4afc2..78678bde81 100644 --- a/spec/lib/activitypub/activity/update_spec.rb +++ b/spec/lib/activitypub/activity/update_spec.rb @@ -257,7 +257,7 @@ RSpec.describe ActivityPub::Activity::Update do 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(:featured_collection_json) do { diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 8786760125..a128a9b2f8 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -802,23 +802,17 @@ RSpec.describe Account do let(:discoverable) { true } let(:feature_approval_policy) { (0b10 << 16) | 0 } - it 'returns `false`' do - expect(subject.featureable_by?(local_account)).to be false + context 'when the policy allows it' do + it 'returns `true`' do + expect(subject.featureable_by?(local_account)).to be true + end end - context 'when collections federation is enabled', feature: :collections_federation do - context 'when the policy allows it' do - it 'returns `true`' do - expect(subject.featureable_by?(local_account)).to be true - end - end + context 'when the policy forbids it' do + let(:feature_approval_policy) { 0 } - context 'when the policy forbids it' do - let(:feature_approval_policy) { 0 } - - it 'returns `false`' do - expect(subject.featureable_by?(local_account)).to be false - end + it 'returns `false`' do + expect(subject.featureable_by?(local_account)).to be false end end end diff --git a/spec/services/activitypub/process_account_service_spec.rb b/spec/services/activitypub/process_account_service_spec.rb index 99bcbba9fe..96923a816e 100644 --- a/spec/services/activitypub/process_account_service_spec.rb +++ b/spec/services/activitypub/process_account_service_spec.rb @@ -63,7 +63,7 @@ RSpec.describe ActivityPub::ProcessAccountService do end end - context 'with collection URIs', feature: :collections_federation do + context 'with collection URIs', feature: :collections do let(:payload) do { 'id' => 'https://foo.test', diff --git a/spec/services/add_account_to_collection_service_spec.rb b/spec/services/add_account_to_collection_service_spec.rb index c1e3ab45c8..4f87a2e1b9 100644 --- a/spec/services/add_account_to_collection_service_spec.rb +++ b/spec/services/add_account_to_collection_service_spec.rb @@ -22,14 +22,14 @@ RSpec.describe AddAccountToCollectionService do end 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) expect(ActivityPub::AccountRawDistributionWorker).to have_enqueued_sidekiq_job 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)) } it 'marks the item as `pending` and federates a `FeatureRequest` activity' do diff --git a/spec/services/create_collection_service_spec.rb b/spec/services/create_collection_service_spec.rb index 976782679f..ded9d4d567 100644 --- a/spec/services/create_collection_service_spec.rb +++ b/spec/services/create_collection_service_spec.rb @@ -29,7 +29,7 @@ RSpec.describe CreateCollectionService do expect(collection).to be_local end - it 'federates an `Add` activity', feature: :collections_federation do + it 'federates an `Add` activity' do subject.call(base_params, author) expect(ActivityPub::AccountRawDistributionWorker).to have_enqueued_sidekiq_job @@ -65,7 +65,7 @@ RSpec.describe CreateCollectionService do context 'when some accounts are remote' do 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) new_collection = author.collections.last diff --git a/spec/services/delete_collection_item_service_spec.rb b/spec/services/delete_collection_item_service_spec.rb index d7bfb97f67..f9a235b902 100644 --- a/spec/services/delete_collection_item_service_spec.rb +++ b/spec/services/delete_collection_item_service_spec.rb @@ -14,7 +14,7 @@ RSpec.describe DeleteCollectionItemService do end 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) expect(ActivityPub::AccountRawDistributionWorker).to have_enqueued_sidekiq_job @@ -33,7 +33,7 @@ RSpec.describe DeleteCollectionItemService do let(:collection) { Fabricate(:remote_collection) } 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(ActivityPub::AccountRawDistributionWorker).to_not have_enqueued_sidekiq_job diff --git a/spec/services/delete_collection_service_spec.rb b/spec/services/delete_collection_service_spec.rb index bd4ed5fef6..06ed82b21d 100644 --- a/spec/services/delete_collection_service_spec.rb +++ b/spec/services/delete_collection_service_spec.rb @@ -12,7 +12,7 @@ RSpec.describe DeleteCollectionService do expect { subject.call(collection) }.to change(Collection, :count).by(-1) end - it 'federates a `Remove` activity', feature: :collections_federation do + it 'federates a `Remove` activity' do subject.call(collection) expect(ActivityPub::AccountRawDistributionWorker).to have_enqueued_sidekiq_job diff --git a/spec/services/revoke_collection_item_service_spec.rb b/spec/services/revoke_collection_item_service_spec.rb index b4cba82056..18357f53dd 100644 --- a/spec/services/revoke_collection_item_service_spec.rb +++ b/spec/services/revoke_collection_item_service_spec.rb @@ -12,7 +12,7 @@ RSpec.describe RevokeCollectionItemService do .to change { collection_item.reload.state }.from('accepted').to('revoked') 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(:collection) { Fabricate(:remote_collection, account:) } let(:collection_item) { Fabricate(:collection_item, collection:, uri: 'https://example.com') } diff --git a/spec/services/update_collection_service_spec.rb b/spec/services/update_collection_service_spec.rb index b7b9547dbb..32dd88216c 100644 --- a/spec/services/update_collection_service_spec.rb +++ b/spec/services/update_collection_service_spec.rb @@ -16,7 +16,7 @@ RSpec.describe UpdateCollectionService do end 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' }) expect(ActivityPub::AccountRawDistributionWorker).to have_enqueued_sidekiq_job @@ -24,7 +24,7 @@ RSpec.describe UpdateCollectionService do end 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 }) expect(ActivityPub::AccountRawDistributionWorker).to_not have_enqueued_sidekiq_job