diff --git a/app/controllers/activitypub/contexts_controller.rb b/app/controllers/activitypub/contexts_controller.rb index 4daa75552..efe215cd1 100644 --- a/app/controllers/activitypub/contexts_controller.rb +++ b/app/controllers/activitypub/contexts_controller.rb @@ -36,9 +36,8 @@ class ActivityPub::ContextsController < ActivityPub::BaseController def context_presenter first_page = ActivityPub::CollectionPresenter.new( - id: items_context_url(@conversation, page_params), type: :unordered, - part_of: items_context_url(@conversation), + part_of: context_url(@conversation), next: next_page, items: @items.map { |status| status.local? ? ActivityPub::TagManager.instance.uri_for(status) : status.uri } ) @@ -52,7 +51,7 @@ class ActivityPub::ContextsController < ActivityPub::BaseController page = ActivityPub::CollectionPresenter.new( id: items_context_url(@conversation, page_params), type: :unordered, - part_of: items_context_url(@conversation), + part_of: context_url(@conversation), next: next_page, items: @items.map { |status| status.local? ? ActivityPub::TagManager.instance.uri_for(status) : status.uri } ) diff --git a/app/serializers/activitypub/context_serializer.rb b/app/serializers/activitypub/context_serializer.rb index 33c70d8e9..70f5e7dd4 100644 --- a/app/serializers/activitypub/context_serializer.rb +++ b/app/serializers/activitypub/context_serializer.rb @@ -3,7 +3,9 @@ class ActivityPub::ContextSerializer < ActivityPub::Serializer include RoutingHelper - attributes :id, :type, :attributed_to, :first + attributes :id, :type, :attributed_to + + has_one :first, serializer: ActivityPub::CollectionSerializer def type 'Collection' diff --git a/spec/requests/activitypub/contexts_spec.rb b/spec/requests/activitypub/contexts_spec.rb index c69443d7b..65b306a87 100644 --- a/spec/requests/activitypub/contexts_spec.rb +++ b/spec/requests/activitypub/contexts_spec.rb @@ -24,6 +24,11 @@ RSpec.describe 'ActivityPub Contexts' do expect(response.parsed_body[:type]) .to eq 'Collection' + expect(response.parsed_body[:first]) + .to include( + type: 'CollectionPage', + partOf: context_url(conversation) + ) expect(response.parsed_body[:first][:items]) .to be_an(Array) .and have_attributes(size: 2)