From bcead764109bff870cb24628e9bf4c9bbcd25bd9 Mon Sep 17 00:00:00 2001 From: David Roetzel Date: Wed, 25 Mar 2026 14:04:09 +0100 Subject: [PATCH] Only federate accepted collection items (#38385) --- .../activitypub/featured_collections_controller.rb | 4 +++- .../activitypub/featured_collection_serializer.rb | 4 ++++ .../featured_collection_serializer_spec.rb | 13 +++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/controllers/activitypub/featured_collections_controller.rb b/app/controllers/activitypub/featured_collections_controller.rb index 872d03423d..09de5583cc 100644 --- a/app/controllers/activitypub/featured_collections_controller.rb +++ b/app/controllers/activitypub/featured_collections_controller.rb @@ -33,7 +33,9 @@ class ActivityPub::FeaturedCollectionsController < ApplicationController def set_collections authorize @account, :index_collections? - @collections = @account.collections.page(params[:page]).per(PER_PAGE) + @collections = @account.collections + .includes(:accepted_collection_items) + .page(params[:page]).per(PER_PAGE) rescue Mastodon::NotPermittedError not_found end diff --git a/app/serializers/activitypub/featured_collection_serializer.rb b/app/serializers/activitypub/featured_collection_serializer.rb index d6242b9d5b..e37085d422 100644 --- a/app/serializers/activitypub/featured_collection_serializer.rb +++ b/app/serializers/activitypub/featured_collection_serializer.rb @@ -46,4 +46,8 @@ class ActivityPub::FeaturedCollectionSerializer < ActivityPub::Serializer def language_present? object.language.present? end + + def collection_items + object.accepted_collection_items + end end diff --git a/spec/serializers/activitypub/featured_collection_serializer_spec.rb b/spec/serializers/activitypub/featured_collection_serializer_spec.rb index c0ae43abb9..b25ec13a52 100644 --- a/spec/serializers/activitypub/featured_collection_serializer_spec.rb +++ b/spec/serializers/activitypub/featured_collection_serializer_spec.rb @@ -67,4 +67,17 @@ RSpec.describe ActivityPub::FeaturedCollectionSerializer do expect(subject).to_not have_key('summary') end end + + context 'when not all items are accepted' do + before do + collection_items.first.update!(state: :pending) + end + + it 'only includes accepted items' do + items = subject['orderedItems'] + + expect(items.size).to eq 1 + expect(items.first['id']).to eq ActivityPub::TagManager.instance.uri_for(collection_items.last) + end + end end