mirror of
https://github.com/glitch-soc/mastodon.git
synced 2026-03-29 03:00:33 +02:00
Only federate accepted collection items (#38385)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user