diff --git a/app/controllers/activitypub/featured_collections_controller.rb b/app/controllers/activitypub/featured_collections_controller.rb index 09de5583cc..12c0648fae 100644 --- a/app/controllers/activitypub/featured_collections_controller.rb +++ b/app/controllers/activitypub/featured_collections_controller.rb @@ -9,7 +9,6 @@ class ActivityPub::FeaturedCollectionsController < ApplicationController vary_by -> { public_fetch_mode? ? 'Accept, Accept-Language, Cookie' : 'Accept, Accept-Language, Cookie, Signature' } - before_action :check_feature_enabled before_action :require_account_signature!, if: -> { authorized_fetch_mode? } before_action :set_collections @@ -72,8 +71,4 @@ class ActivityPub::FeaturedCollectionsController < ApplicationController ) end end - - def check_feature_enabled - raise ActionController::RoutingError unless Mastodon::Feature.collections_enabled? - end end diff --git a/app/controllers/admin/report_notes_controller.rb b/app/controllers/admin/report_notes_controller.rb index 10dbe846e4..03234b0bde 100644 --- a/app/controllers/admin/report_notes_controller.rb +++ b/app/controllers/admin/report_notes_controller.rb @@ -25,6 +25,8 @@ module Admin @action_logs = @report.history.includes(:target) @form = Admin::StatusBatchAction.new @statuses = @report.statuses.with_includes + @collections = @report.collections + @collection_form = Admin::CollectionBatchAction.new render 'admin/reports/show' end diff --git a/app/controllers/api/v1/collection_items_controller.rb b/app/controllers/api/v1/collection_items_controller.rb index eaa46a4430..3ec5e18ed9 100644 --- a/app/controllers/api/v1/collection_items_controller.rb +++ b/app/controllers/api/v1/collection_items_controller.rb @@ -3,8 +3,6 @@ class Api::V1::CollectionItemsController < Api::BaseController include Authorization - before_action :check_feature_enabled - before_action -> { doorkeeper_authorize! :write, :'write:collections' } before_action :require_user! @@ -55,8 +53,4 @@ class Api::V1::CollectionItemsController < Api::BaseController def set_collection_item @collection_item = @collection.collection_items.find(params[:id]) end - - def check_feature_enabled - raise ActionController::RoutingError unless Mastodon::Feature.collections_enabled? - end end diff --git a/app/controllers/api/v1/collections_controller.rb b/app/controllers/api/v1/collections_controller.rb index 3c1841237d..9acd535f46 100644 --- a/app/controllers/api/v1/collections_controller.rb +++ b/app/controllers/api/v1/collections_controller.rb @@ -9,8 +9,6 @@ class Api::V1::CollectionsController < Api::BaseController render json: { error: ValidationErrorFormatter.new(e).as_json }, status: 422 end - before_action :check_feature_enabled - before_action -> { authorize_if_got_token! :read, :'read:collections' }, only: [:index, :show] before_action -> { doorkeeper_authorize! :write, :'write:collections' }, only: [:create, :update, :destroy] @@ -91,10 +89,6 @@ class Api::V1::CollectionsController < Api::BaseController params.permit(:name, :description, :language, :sensitive, :discoverable, :tag_name) end - def check_feature_enabled - raise ActionController::RoutingError unless Mastodon::Feature.collections_enabled? - end - def next_path return unless records_continue? diff --git a/app/controllers/api/v1/in_collections_controller.rb b/app/controllers/api/v1/in_collections_controller.rb index 54a1334e3c..c34845e463 100644 --- a/app/controllers/api/v1/in_collections_controller.rb +++ b/app/controllers/api/v1/in_collections_controller.rb @@ -5,8 +5,6 @@ class Api::V1::InCollectionsController < Api::BaseController DEFAULT_COLLECTIONS_LIMIT = 40 - before_action :check_feature_enabled - before_action -> { authorize_if_got_token! :read, :'read:collections' }, only: [:index] before_action :require_user! @@ -37,10 +35,6 @@ class Api::V1::InCollectionsController < Api::BaseController .limit(limit_param(DEFAULT_COLLECTIONS_LIMIT)) end - def check_feature_enabled - raise ActionController::RoutingError unless Mastodon::Feature.collections_enabled? - end - def next_path return unless records_continue? diff --git a/app/controllers/api/v1/reports_controller.rb b/app/controllers/api/v1/reports_controller.rb index 8e341aa48e..a8653631c2 100644 --- a/app/controllers/api/v1/reports_controller.rb +++ b/app/controllers/api/v1/reports_controller.rb @@ -23,10 +23,6 @@ class Api::V1::ReportsController < Api::BaseController end def report_params - if Mastodon::Feature.collections_enabled? - params.permit(:account_id, :comment, :category, :forward, forward_to_domains: [], status_ids: [], collection_ids: [], rule_ids: []) - else - params.permit(:account_id, :comment, :category, :forward, forward_to_domains: [], status_ids: [], rule_ids: []) - end + params.permit(:account_id, :comment, :category, :forward, forward_to_domains: [], status_ids: [], collection_ids: [], rule_ids: []) end end diff --git a/app/controllers/api/v1/statuses_controller.rb b/app/controllers/api/v1/statuses_controller.rb index 78b237357c..d3f742d62a 100644 --- a/app/controllers/api/v1/statuses_controller.rb +++ b/app/controllers/api/v1/statuses_controller.rb @@ -170,6 +170,6 @@ class Api::V1::StatusesController < Api::BaseController end def serialized_accounts(accounts) - ActiveModel::Serializer::CollectionSerializer.new(accounts, serializer: REST::AccountSerializer) + ActiveModel::Serializer::CollectionSerializer.new(accounts, serializer: REST::AccountSerializer, scope_name: :current_user, scope: current_user) end end diff --git a/app/controllers/collection_items_controller.rb b/app/controllers/collection_items_controller.rb index 09c1e0e192..51044b5965 100644 --- a/app/controllers/collection_items_controller.rb +++ b/app/controllers/collection_items_controller.rb @@ -7,7 +7,6 @@ class CollectionItemsController < ApplicationController vary_by -> { public_fetch_mode? ? 'Accept, Accept-Language, Cookie' : 'Accept, Accept-Language, Cookie, Signature' } - before_action :check_feature_enabled before_action :require_account_signature!, if: -> { authorized_fetch_mode? } before_action :set_collection_item @@ -35,8 +34,4 @@ class CollectionItemsController < ApplicationController rescue ActiveRecord::RecordNotFound, Mastodon::NotPermittedError not_found end - - def check_feature_enabled - raise ActionController::RoutingError unless Mastodon::Feature.collections_enabled? - end end diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb index 70541433f0..628418557c 100644 --- a/app/controllers/collections_controller.rb +++ b/app/controllers/collections_controller.rb @@ -8,7 +8,6 @@ class CollectionsController < ApplicationController vary_by -> { public_fetch_mode? ? 'Accept, Accept-Language, Cookie' : 'Accept, Accept-Language, Cookie, Signature' } - before_action :check_feature_enabled before_action :require_account_signature!, only: :show, if: -> { request.format == :json && authorized_fetch_mode? } before_action :set_collection @@ -51,8 +50,4 @@ class CollectionsController < ApplicationController recently_updated = @collection.updated_at > 15.minutes.ago recently_updated ? 30.seconds : 5.minutes end - - def check_feature_enabled - raise ActionController::RoutingError unless Mastodon::Feature.collections_enabled? - end end diff --git a/app/lib/activitypub/activity/accept.rb b/app/lib/activitypub/activity/accept.rb index 4dc6977b8e..a76b79a6d8 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_enabled? && feature_request_from_object.present? + return accept_feature_request! if 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 0d22910a9a..957471a5c6 100644 --- a/app/lib/activitypub/activity/add.rb +++ b/app/lib/activitypub/activity/add.rb @@ -13,12 +13,10 @@ class ActivityPub::Activity::Add < ActivityPub::Activity add_featured end when @account.collections_url - 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_enabled? + add_collection_item if @collection end end diff --git a/app/lib/activitypub/activity/delete.rb b/app/lib/activitypub/activity/delete.rb index 1239462a11..1e3cd1a647 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_enabled? || feature_authorization_from_object.nil? + return delete_feature_authorization! unless 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 16a3860a0e..2738618767 100644 --- a/app/lib/activitypub/activity/feature_request.rb +++ b/app/lib/activitypub/activity/feature_request.rb @@ -4,7 +4,6 @@ class ActivityPub::Activity::FeatureRequest < ActivityPub::Activity include Payloadable def perform - 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 8eb2427a84..87d5a5fad5 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_enabled? + elsif equals_or_includes_any?(@object['type'], ['FeaturedCollection']) update_collection end end diff --git a/app/lib/status_cache_hydrator.rb b/app/lib/status_cache_hydrator.rb index d5920530c6..ece88c04c1 100644 --- a/app/lib/status_cache_hydrator.rb +++ b/app/lib/status_cache_hydrator.rb @@ -121,7 +121,6 @@ class StatusCacheHydrator end def hydrate_account(payload, account) - return unless Mastodon::Feature.collections_enabled? return unless payload[:id] stale_account = Account.find_by(id: payload[:id]) diff --git a/app/serializers/activitypub/actor_serializer.rb b/app/serializers/activitypub/actor_serializer.rb index 8212b607f6..38b0878b1a 100644 --- a/app/serializers/activitypub/actor_serializer.rb +++ b/app/serializers/activitypub/actor_serializer.rb @@ -10,7 +10,7 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer :moved_to, :property_value, :discoverable, :suspended, :memorial, :indexable, :attribution_domains, :profile_settings - context_extensions :interaction_policies if Mastodon::Feature.collections_enabled? + context_extensions :interaction_policies attributes :id, :webfinger, :type, :following, :followers, :inbox, :outbox, :featured, :featured_tags, @@ -21,8 +21,8 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer attribute :show_media_replies, key: :show_replies_in_media - attribute :interaction_policy, if: -> { Mastodon::Feature.collections_enabled? } - attribute :featured_collections, if: -> { Mastodon::Feature.collections_enabled? } + attribute :interaction_policy + attribute :featured_collections has_one :public_key, serializer: ActivityPub::PublicKeySerializer diff --git a/app/serializers/rest/account_serializer.rb b/app/serializers/rest/account_serializer.rb index 8afe3f3b67..e24cdfab85 100644 --- a/app/serializers/rest/account_serializer.rb +++ b/app/serializers/rest/account_serializer.rb @@ -21,7 +21,7 @@ class REST::AccountSerializer < ActiveModel::Serializer attribute :memorial, if: :memorial? - attribute :feature_approval, if: -> { Mastodon::Feature.collections_enabled? } + attribute :feature_approval attribute :email_subscriptions, if: -> { Rails.application.config.x.email_subscriptions && Setting.email_subscriptions } class AccountDecorator < SimpleDelegator diff --git a/app/serializers/rest/role_serializer.rb b/app/serializers/rest/role_serializer.rb index a3d8af64b2..424b3401da 100644 --- a/app/serializers/rest/role_serializer.rb +++ b/app/serializers/rest/role_serializer.rb @@ -3,7 +3,7 @@ class REST::RoleSerializer < ActiveModel::Serializer attributes :id, :name, :permissions, :color, :highlighted - attribute :collection_limit, if: -> { Mastodon::Feature.collections_enabled? } + attribute :collection_limit def id object.id.to_s diff --git a/app/services/activitypub/process_account_service.rb b/app/services/activitypub/process_account_service.rb index 6254539327..e616400c93 100644 --- a/app/services/activitypub/process_account_service.rb +++ b/app/services/activitypub/process_account_service.rb @@ -72,7 +72,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_enabled? + check_featured_collections_collection! if @json['featuredCollections'].present? check_links! if @account.fields.any?(&:requires_verification?) end @@ -121,7 +121,7 @@ class ActivityPub::ProcessAccountService < BaseService @account.uri = @uri @account.actor_type = actor_type @account.created_at = @json['published'] if @json['published'].present? - @account.feature_approval_policy = feature_approval_policy if Mastodon::Feature.collections_enabled? + @account.feature_approval_policy = feature_approval_policy end def valid_collection_uri(uri) diff --git a/app/services/resolve_url_service.rb b/app/services/resolve_url_service.rb index 9a136439b0..5c27121acd 100644 --- a/app/services/resolve_url_service.rb +++ b/app/services/resolve_url_service.rb @@ -28,7 +28,7 @@ class ResolveURLService < BaseService status = FetchRemoteStatusService.new.call(resource_url, prefetched_body: body) authorize_with @on_behalf_of, status, :show? unless status.nil? status - elsif type == 'FeaturedCollection' && Mastodon::Feature.collections_enabled? + elsif type == 'FeaturedCollection' collection = ActivityPub::FetchRemoteFeaturedCollectionService.new.call(resource_url, prefetched_body: body) authorize_with @on_behalf_of, collection, :show? unless collection.nil? collection diff --git a/app/views/admin/reports/index.html.haml b/app/views/admin/reports/index.html.haml index 070d8c8518..b6b25c190e 100644 --- a/app/views/admin/reports/index.html.haml +++ b/app/views/admin/reports/index.html.haml @@ -67,10 +67,9 @@ = material_symbol('photo_camera') = report.media_attachments_count - - if Mastodon::Feature.collections_enabled? - %span.report-card__summary__item__content__icon{ title: t('admin.accounts.collections') } - = material_symbol('category') - = report.collections.size + %span.report-card__summary__item__content__icon{ title: t('admin.accounts.collections') } + = material_symbol('category') + = report.collections.size - if report.forwarded? ยท diff --git a/app/views/admin/reports/show.html.haml b/app/views/admin/reports/show.html.haml index bae69cca04..d23edee3c4 100644 --- a/app/views/admin/reports/show.html.haml +++ b/app/views/admin/reports/show.html.haml @@ -62,27 +62,26 @@ - else = render partial: 'admin/shared/status_batch_row', collection: @statuses, as: :status, locals: { f: f } -- if Mastodon::Feature.collections_enabled? - %details{ open: @collections.any? } - %summary - = t 'admin.reports.collections', count: @collections.size +%details{ open: @collections.any? } + %summary + = t 'admin.reports.collections', count: @collections.size - = form_with model: @collection_form, url: batch_admin_account_collections_path(@report.target_account_id, report_id: @report.id) do |f| - .batch-table - .batch-table__toolbar - %label.batch-table__toolbar__select.batch-checkbox-all - = check_box_tag :batch_checkbox_all, nil, false - .batch-table__toolbar__actions - = link_to safe_join([material_symbol('add'), t('admin.reports.add_to_report')]), - admin_account_collections_path(@report.target_account_id, report_id: @report.id), - class: 'table-action-link' - - if !@collections.empty? && @report.unresolved? - = f.button safe_join([material_symbol('close'), t('admin.collections.batch.remove_from_report')]), name: :remove_from_report, class: 'table-action-link', type: :submit - .batch-table__body - - if @collections.empty? - = nothing_here 'nothing-here--under-tabs' - - else - = render partial: 'admin/shared/collection_batch_row', collection: @collections, as: :collection, locals: { f: f } + = form_with model: @collection_form, url: batch_admin_account_collections_path(@report.target_account_id, report_id: @report.id) do |f| + .batch-table + .batch-table__toolbar + %label.batch-table__toolbar__select.batch-checkbox-all + = check_box_tag :batch_checkbox_all, nil, false + .batch-table__toolbar__actions + = link_to safe_join([material_symbol('add'), t('admin.reports.add_to_report')]), + admin_account_collections_path(@report.target_account_id, report_id: @report.id), + class: 'table-action-link' + - if !@collections.empty? && @report.unresolved? + = f.button safe_join([material_symbol('close'), t('admin.collections.batch.remove_from_report')]), name: :remove_from_report, class: 'table-action-link', type: :submit + .batch-table__body + - if @collections.empty? + = nothing_here 'nothing-here--under-tabs' + - else + = render partial: 'admin/shared/collection_batch_row', collection: @collections, as: :collection, locals: { f: f } - if @report.unresolved? %hr.spacer/ diff --git a/app/views/admin/roles/_form.html.haml b/app/views/admin/roles/_form.html.haml index 51114beac1..7246357e67 100644 --- a/app/views/admin/roles/_form.html.haml +++ b/app/views/admin/roles/_form.html.haml @@ -32,13 +32,11 @@ %hr.spacer/ -- if Mastodon::Feature.collections_enabled? +.fields-group + = form.input :collection_limit, + wrapper: :with_label - .fields-group - = form.input :collection_limit, - wrapper: :with_label - - %hr.spacer/ +%hr.spacer/ - unless current_user.role == form.object diff --git a/spec/lib/activitypub/activity/accept_spec.rb b/spec/lib/activitypub/activity/accept_spec.rb index 732f01cc6d..7775143e88 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 do + context 'with a FeatureRequest' 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 b444f38a3d..201953087f 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 do + context 'when the target is the `featuredCollections` collection' 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 do + context 'when the target is a collection' 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 c6d74b4b5b..7e5d5f8574 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 do + context 'with a FeatureAuthorization' 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 5d134b6ceb..3efdf33b35 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 do + describe '#perform' 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 701a2ff1f5..c281d03a94 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 do + context 'with a `FeaturedCollection` object' do let(:collection) { Fabricate(:remote_collection, account: sender, name: 'old name', discoverable: false) } let(:account) { Fabricate(:account) } let!(:collection_item) { Fabricate(:collection_item, account:, collection:, uri: 'https://example.com/featured_stamps/1') } diff --git a/spec/lib/status_cache_hydrator_spec.rb b/spec/lib/status_cache_hydrator_spec.rb index 03e453c046..3eb781dfba 100644 --- a/spec/lib/status_cache_hydrator_spec.rb +++ b/spec/lib/status_cache_hydrator_spec.rb @@ -6,7 +6,7 @@ RSpec.describe StatusCacheHydrator do let(:status) { Fabricate(:status) } let(:account) { Fabricate(:account) } - describe '#hydrate', feature: :collections do + describe '#hydrate' do let(:compare_to_hash) { InlineRenderer.render(status, account, :status) } shared_examples 'shared behavior' do diff --git a/spec/models/admin/moderation_action_spec.rb b/spec/models/admin/moderation_action_spec.rb index fd2e7a4c4c..c49e7c9a30 100644 --- a/spec/models/admin/moderation_action_spec.rb +++ b/spec/models/admin/moderation_action_spec.rb @@ -33,7 +33,7 @@ RSpec.describe Admin::ModerationAction do expect(report.reload).to be_action_taken end - context 'with attached collections', feature: :collections do + context 'with attached collections' do let(:status_ids) { [] } let(:collections) { Fabricate.times(2, :collection, account: target_account) } @@ -47,7 +47,7 @@ RSpec.describe Admin::ModerationAction do end end - context 'with a remote collection', feature: :collections do + context 'with a remote collection' do let(:status_ids) { [] } let(:collection) { Fabricate(:remote_collection) } let(:target_account) { collection.account } @@ -83,7 +83,7 @@ RSpec.describe Admin::ModerationAction do expect(report.reload).to be_action_taken end - context 'with attached collections', feature: :collections do + context 'with attached collections' do let(:status_ids) { [] } let(:collections) { Fabricate.times(2, :collection, account: target_account) } diff --git a/spec/requests/activitypub/featured_collections_spec.rb b/spec/requests/activitypub/featured_collections_spec.rb index 09a17c53be..c4601df69b 100644 --- a/spec/requests/activitypub/featured_collections_spec.rb +++ b/spec/requests/activitypub/featured_collections_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe 'Collections' do - describe 'GET /ap/users/@:account_id/featured_collections', feature: :collections do + describe 'GET /ap/users/@:account_id/featured_collections' do subject { get ap_account_featured_collections_path(account.id, format: :json) } let(:collection) { Fabricate(:collection) } diff --git a/spec/requests/admin/reports_spec.rb b/spec/requests/admin/reports_spec.rb index d44db63795..2e361e43df 100644 --- a/spec/requests/admin/reports_spec.rb +++ b/spec/requests/admin/reports_spec.rb @@ -47,7 +47,7 @@ RSpec.describe 'Admin Reports' do it_behaves_like 'successful return' end - context 'with a reported collection', feature: :collections do + context 'with a reported collection' do before do report.collections << Fabricate(:collection, account: report.target_account) end @@ -55,7 +55,7 @@ RSpec.describe 'Admin Reports' do it_behaves_like 'successful return' end - context 'with both status and collection', feature: :collections do + context 'with both status and collection' do before do status = Fabricate(:status, account: report.target_account) report.update(status_ids: [status.id]) diff --git a/spec/requests/api/v1/collection_items_spec.rb b/spec/requests/api/v1/collection_items_spec.rb index e7ee854e67..93d4f70ad5 100644 --- a/spec/requests/api/v1/collection_items_spec.rb +++ b/spec/requests/api/v1/collection_items_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'Api::V1Alpha::CollectionItems', feature: :collections do +RSpec.describe 'Api::V1Alpha::CollectionItems' do include_context 'with API authentication', oauth_scopes: 'read:collections write:collections' describe 'POST /api/v1_alpha/collections/:collection_id/items' do diff --git a/spec/requests/api/v1/collections_spec.rb b/spec/requests/api/v1/collections_spec.rb index 4bf296f293..b6bb17319d 100644 --- a/spec/requests/api/v1/collections_spec.rb +++ b/spec/requests/api/v1/collections_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'Api::V1::Collections', feature: :collections do +RSpec.describe 'Api::V1::Collections' do include_context 'with API authentication', oauth_scopes: 'read:collections write:collections' describe 'GET /api/v1/accounts/:account_id/collections' do diff --git a/spec/requests/api/v1/in_collections_spec.rb b/spec/requests/api/v1/in_collections_spec.rb index 3c41feb2e7..74902fe09e 100644 --- a/spec/requests/api/v1/in_collections_spec.rb +++ b/spec/requests/api/v1/in_collections_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'Api::V1::InCollections', feature: :collections do +RSpec.describe 'Api::V1::InCollections' do include_context 'with API authentication', oauth_scopes: 'read:collections write:collections' describe 'GET /api/v1/in_collections' do diff --git a/spec/requests/api/v1/reports_spec.rb b/spec/requests/api/v1/reports_spec.rb index 247ff979c5..6b344eaac8 100644 --- a/spec/requests/api/v1/reports_spec.rb +++ b/spec/requests/api/v1/reports_spec.rb @@ -113,7 +113,7 @@ RSpec.describe 'Reports' do end end - context 'with attached collection', feature: :collections do + context 'with attached collection' do let(:collection) { Fabricate(:collection, account: target_account) } let(:collection_ids) { [collection.id] } diff --git a/spec/requests/collection_items_spec.rb b/spec/requests/collection_items_spec.rb index f0802fc3f3..703e6bdba3 100644 --- a/spec/requests/collection_items_spec.rb +++ b/spec/requests/collection_items_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe 'CollectionItems' do - describe 'GET /ap/users/@:account_id/collection_items/:id', feature: :collections do + describe 'GET /ap/users/@:account_id/collection_items/:id' do subject { get ap_account_collection_item_path(account.id, collection_item, format: :json) } let(:collection_item) { Fabricate(:collection_item) } diff --git a/spec/requests/collections_spec.rb b/spec/requests/collections_spec.rb index bdebb03f60..dbdf1c16a2 100644 --- a/spec/requests/collections_spec.rb +++ b/spec/requests/collections_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe 'Collections' do - describe 'GET /collections/:id', feature: :collections do + describe 'GET /collections/:id' do subject { get collection_path(collection) } let(:collection) { Fabricate(:collection) } @@ -15,7 +15,7 @@ RSpec.describe 'Collections' do end end - describe 'GET /ap/:account_id/collections/:id', feature: :collections do + describe 'GET /ap/:account_id/collections/:id' do subject { get ap_account_collection_path(account.id, collection, format: :json) } let(:collection) { Fabricate(:collection) } diff --git a/spec/serializers/activitypub/actor_serializer_spec.rb b/spec/serializers/activitypub/actor_serializer_spec.rb index 73702c979c..661890f33b 100644 --- a/spec/serializers/activitypub/actor_serializer_spec.rb +++ b/spec/serializers/activitypub/actor_serializer_spec.rb @@ -40,46 +40,37 @@ RSpec.describe ActivityPub::ActorSerializer do describe '#interactionPolicy' do let(:record) { Fabricate(:account) } - # TODO: Remove when feature flag is removed - context 'when collections feature is disabled?' do - it 'is not present' do - expect(subject).to_not have_key('interactionPolicy') + context 'when actor is discoverable' do + it 'includes an automatic policy allowing everyone' do + expect(subject).to include('interactionPolicy' => { + 'canFeature' => { + 'automaticApproval' => ['https://www.w3.org/ns/activitystreams#Public'], + }, + }) + end + + context 'when actor is locked' do + let(:record) { Fabricate(:account, locked: true) } + + it 'includes an automatic policy allowing followers' do + expect(subject).to include('interactionPolicy' => { + 'canFeature' => { + 'automaticApproval' => [ActivityPub::TagManager.instance.followers_uri_for(record)], + }, + }) + end end end - context 'when collections feature is enabled', feature: :collections do - context 'when actor is discoverable' do - it 'includes an automatic policy allowing everyone' do - expect(subject).to include('interactionPolicy' => { - 'canFeature' => { - 'automaticApproval' => ['https://www.w3.org/ns/activitystreams#Public'], - }, - }) - end + context 'when actor is not discoverable' do + let(:record) { Fabricate(:account, discoverable: false) } - context 'when actor is locked' do - let(:record) { Fabricate(:account, locked: true) } - - it 'includes an automatic policy allowing followers' do - expect(subject).to include('interactionPolicy' => { - 'canFeature' => { - 'automaticApproval' => [ActivityPub::TagManager.instance.followers_uri_for(record)], - }, - }) - end - end - end - - context 'when actor is not discoverable' do - let(:record) { Fabricate(:account, discoverable: false) } - - it 'includes an automatic policy limited to the actor itself' do - expect(subject).to include('interactionPolicy' => { - 'canFeature' => { - 'automaticApproval' => [ActivityPub::TagManager.instance.uri_for(record)], - }, - }) - end + it 'includes an automatic policy limited to the actor itself' do + expect(subject).to include('interactionPolicy' => { + 'canFeature' => { + 'automaticApproval' => [ActivityPub::TagManager.instance.uri_for(record)], + }, + }) end end end diff --git a/spec/serializers/activitypub/flag_serializer_spec.rb b/spec/serializers/activitypub/flag_serializer_spec.rb index a66a49bc87..cebf0d2ea7 100644 --- a/spec/serializers/activitypub/flag_serializer_spec.rb +++ b/spec/serializers/activitypub/flag_serializer_spec.rb @@ -38,7 +38,7 @@ RSpec.describe ActivityPub::FlagSerializer do end end - context 'with collection', feature: :collections do + context 'with collection' do let(:target_account) { Fabricate(:account) } let(:collection) { Fabricate(:collection, account: target_account) } let(:report) { Fabricate(:report, target_account:, collections: [collection]) } diff --git a/spec/serializers/rest/account_serializer_spec.rb b/spec/serializers/rest/account_serializer_spec.rb index e8e437cbd3..68e62f7e07 100644 --- a/spec/serializers/rest/account_serializer_spec.rb +++ b/spec/serializers/rest/account_serializer_spec.rb @@ -76,75 +76,66 @@ RSpec.describe REST::AccountSerializer do end describe '#feature_approval' do - # TODO: Remove when feature flag is removed - context 'when collections feature is disabled' do - it 'does not include the approval policy' do - expect(subject).to_not have_key('feature_approval') - end - end - - context 'when collections feature is enabled', feature: :collections do - context 'when account is local' do - context 'when account is discoverable' do - it 'includes a policy that allows featuring' do - expect(subject['feature_approval']).to include({ - 'automatic' => ['public'], - 'manual' => [], - 'current_user' => 'automatic', - }) - end - - context 'when account is locked' do - let(:account) { Fabricate(:account, locked: true) } - - context 'when the current account does not follow the user' do - it 'includes a policy that allows featuring for followers and has "denied" for the current user' do - expect(subject['feature_approval']).to include({ - 'automatic' => ['followers'], - 'manual' => [], - 'current_user' => 'denied', - }) - end - end - - context 'when the current account follows the user' do - before { current_user.account.follow!(account) } - - it 'includes a policy that allows featuring for followers and has "automatic" for the current user' do - expect(subject['feature_approval']).to include({ - 'automatic' => ['followers'], - 'manual' => [], - 'current_user' => 'automatic', - }) - end - end - end - end - - context 'when account is not discoverable' do - let(:account) { Fabricate(:account, discoverable: false) } - - it 'includes a policy that disallows featuring' do - expect(subject['feature_approval']).to include({ - 'automatic' => [], - 'manual' => [], - 'current_user' => 'denied', - }) - end - end - end - - context 'when account is remote' do - let(:account) { Fabricate(:account, domain: 'example.com', feature_approval_policy: 0b11000000000000000010) } - - it 'includes the matching policy' do + context 'when account is local' do + context 'when account is discoverable' do + it 'includes a policy that allows featuring' do expect(subject['feature_approval']).to include({ - 'automatic' => ['followers', 'following'], - 'manual' => ['public'], - 'current_user' => 'manual', + 'automatic' => ['public'], + 'manual' => [], + 'current_user' => 'automatic', + }) + end + + context 'when account is locked' do + let(:account) { Fabricate(:account, locked: true) } + + context 'when the current account does not follow the user' do + it 'includes a policy that allows featuring for followers and has "denied" for the current user' do + expect(subject['feature_approval']).to include({ + 'automatic' => ['followers'], + 'manual' => [], + 'current_user' => 'denied', + }) + end + end + + context 'when the current account follows the user' do + before { current_user.account.follow!(account) } + + it 'includes a policy that allows featuring for followers and has "automatic" for the current user' do + expect(subject['feature_approval']).to include({ + 'automatic' => ['followers'], + 'manual' => [], + 'current_user' => 'automatic', + }) + end + end + end + end + + context 'when account is not discoverable' do + let(:account) { Fabricate(:account, discoverable: false) } + + it 'includes a policy that disallows featuring' do + expect(subject['feature_approval']).to include({ + 'automatic' => [], + 'manual' => [], + 'current_user' => 'denied', }) end end end + + context 'when account is remote' do + let(:account) { Fabricate(:account, domain: 'example.com', feature_approval_policy: 0b11000000000000000010) } + + it 'includes the matching policy' do + expect(subject['feature_approval']).to include({ + 'automatic' => ['followers', 'following'], + 'manual' => ['public'], + 'current_user' => 'manual', + }) + end + end end end diff --git a/spec/serializers/rest/account_warning_serializer_spec.rb b/spec/serializers/rest/account_warning_serializer_spec.rb index a7a9dc5f63..ebbfebe76a 100644 --- a/spec/serializers/rest/account_warning_serializer_spec.rb +++ b/spec/serializers/rest/account_warning_serializer_spec.rb @@ -3,8 +3,9 @@ require 'rails_helper' RSpec.describe REST::AccountWarningSerializer do - subject { serialized_record_json(record, described_class) } + subject { serialized_record_json(record, described_class, options: { scope: current_user, scope_name: :current_user }) } + let(:current_user) { Fabricate(:moderator_user) } let(:record) { Fabricate :account_warning, id: 123, status_ids: [456, 789] } describe 'serialization' do diff --git a/spec/serializers/rest/admin/account_serializer_spec.rb b/spec/serializers/rest/admin/account_serializer_spec.rb index 5f617207a7..d16b23f112 100644 --- a/spec/serializers/rest/admin/account_serializer_spec.rb +++ b/spec/serializers/rest/admin/account_serializer_spec.rb @@ -3,7 +3,9 @@ require 'rails_helper' RSpec.describe REST::Admin::AccountSerializer do - subject { serialized_record_json(record, described_class) } + subject { serialized_record_json(record, described_class, options: { scope: current_user, scope_name: :current_user }) } + + let(:current_user) { Fabricate(:admin_user) } context 'when created_at is populated' do let(:record) { Fabricate :account, user: Fabricate(:user) } diff --git a/spec/serializers/rest/admin/report_serializer_spec.rb b/spec/serializers/rest/admin/report_serializer_spec.rb index 78d7d4f10a..8be7c9410b 100644 --- a/spec/serializers/rest/admin/report_serializer_spec.rb +++ b/spec/serializers/rest/admin/report_serializer_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe REST::Admin::ReportSerializer do - subject { serialized_record_json(report, described_class) } + subject { serialized_record_json(report, described_class, options: { scope_name: :current_user, scope: nil }) } context 'with timestamps' do let(:report) { Fabricate(:report, action_taken_at: 3.days.ago) } diff --git a/spec/serializers/rest/report_serializer_spec.rb b/spec/serializers/rest/report_serializer_spec.rb index 180cdbdb68..5ffff83220 100644 --- a/spec/serializers/rest/report_serializer_spec.rb +++ b/spec/serializers/rest/report_serializer_spec.rb @@ -6,10 +6,16 @@ RSpec.describe REST::ReportSerializer do subject do serialized_record_json( report, - described_class + described_class, + options: { + scope: current_user, + scope_name: :current_user, + } ) end + let(:current_user) { Fabricate(:moderator_user) } + context 'with timestamps' do let(:report) { Fabricate(:report, action_taken_at: 3.days.ago) } diff --git a/spec/serializers/rest/role_serializer_spec.rb b/spec/serializers/rest/role_serializer_spec.rb index 5b38047587..cb8fd14fc6 100644 --- a/spec/serializers/rest/role_serializer_spec.rb +++ b/spec/serializers/rest/role_serializer_spec.rb @@ -27,7 +27,7 @@ RSpec.describe REST::RoleSerializer do }) end - context 'when collections are enabled', feature: :collections do + context 'when collections are enabled' do it 'includes the relevant attributes' do expect(subject) .to include({ diff --git a/spec/serializers/rest/suggestion_serializer_spec.rb b/spec/serializers/rest/suggestion_serializer_spec.rb index 288d1daa23..a30076ed48 100644 --- a/spec/serializers/rest/suggestion_serializer_spec.rb +++ b/spec/serializers/rest/suggestion_serializer_spec.rb @@ -3,7 +3,8 @@ require 'rails_helper' RSpec.describe REST::SuggestionSerializer do - let(:serialization) { serialized_record_json(record, described_class) } + let(:serialization) { serialized_record_json(record, described_class, options: { scope: current_user, scope_name: :current_user }) } + let(:current_user) { Fabricate(:user) } let(:record) do AccountSuggestions::Suggestion.new( account: account, diff --git a/spec/services/activitypub/process_account_service_spec.rb b/spec/services/activitypub/process_account_service_spec.rb index 96923a816e..56f117ca82 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 do + context 'with collection URIs' do let(:payload) do { 'id' => 'https://foo.test', @@ -562,16 +562,7 @@ RSpec.describe ActivityPub::ProcessAccountService do .to_return(status: 200, body: '', headers: {}) end - # TODO: Remove when feature flag is removed - context 'when collections feature is disabled' do - it 'does not set the interaction policy' do - account = subject.call('user1', 'foo.test', payload) - - expect(account.feature_approval_policy).to be_zero - end - end - - context 'when collections feature is enabled', feature: :collections do + context 'when collections feature is enabled' do it 'sets the interaction policy to the correct value' do account = subject.call('user1', 'foo.test', payload) diff --git a/spec/services/resolve_url_service_spec.rb b/spec/services/resolve_url_service_spec.rb index 6174d8cac9..d5ac5b55b5 100644 --- a/spec/services/resolve_url_service_spec.rb +++ b/spec/services/resolve_url_service_spec.rb @@ -30,7 +30,7 @@ RSpec.describe ResolveURLService do expect(subject.call(url)).to eq known_account end - context 'when searching for a remote collection', feature: :collections do + context 'when searching for a remote collection' do let(:account) { Fabricate(:account) } let(:collection_account) { Fabricate(:account, domain: 'example.com', protocol: :activitypub) } @@ -63,7 +63,7 @@ RSpec.describe ResolveURLService do end end - context 'when searching for a local collection', feature: :collections do + context 'when searching for a local collection' do let(:account) { Fabricate(:account) } let(:collection) { Fabricate(:collection) }