Only federate accepted collection items (#38385)

This commit is contained in:
David Roetzel
2026-03-25 14:04:09 +01:00
committed by GitHub
parent 84ea8334fe
commit bcead76410
3 changed files with 20 additions and 1 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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