Only federate accepted collection items (#38385)
This commit is contained in:
parent
84ea8334fe
commit
bcead76410
@ -33,7 +33,9 @@ class ActivityPub::FeaturedCollectionsController < ApplicationController
|
|||||||
|
|
||||||
def set_collections
|
def set_collections
|
||||||
authorize @account, :index_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
|
rescue Mastodon::NotPermittedError
|
||||||
not_found
|
not_found
|
||||||
end
|
end
|
||||||
|
|||||||
@ -46,4 +46,8 @@ class ActivityPub::FeaturedCollectionSerializer < ActivityPub::Serializer
|
|||||||
def language_present?
|
def language_present?
|
||||||
object.language.present?
|
object.language.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def collection_items
|
||||||
|
object.accepted_collection_items
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -67,4 +67,17 @@ RSpec.describe ActivityPub::FeaturedCollectionSerializer do
|
|||||||
expect(subject).to_not have_key('summary')
|
expect(subject).to_not have_key('summary')
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user