diff options
author | ThibG <thib@sitedethib.com> | 2019-02-28 18:16:34 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2019-02-28 18:16:34 +0100 |
commit | d8498b39838eb352a9b268e0f22b1b025320dc73 (patch) | |
tree | 0a1d8fd3dd955ede6f000f965c508106e21d0753 /app/serializers/activitypub | |
parent | 9d3c6f1849120e732a9230959cb302575765ea8c (diff) |
Give the `replies` collection an identifier and enable pagination (#10128)
Diffstat (limited to 'app/serializers/activitypub')
-rw-r--r-- | app/serializers/activitypub/note_serializer.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/app/serializers/activitypub/note_serializer.rb b/app/serializers/activitypub/note_serializer.rb index 6b0978ad3..4aab993a9 100644 --- a/app/serializers/activitypub/note_serializer.rb +++ b/app/serializers/activitypub/note_serializer.rb @@ -13,7 +13,7 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer has_many :media_attachments, key: :attachment has_many :virtual_tags, key: :tag - has_one :replies, serializer: ActivityPub::CollectionSerializer + has_one :replies, serializer: ActivityPub::CollectionSerializer, if: :local? def id ActivityPub::TagManager.instance.uri_for(object) @@ -36,12 +36,16 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer end def replies + replies = object.self_replies(5).pluck(:id, :uri) + last_id = replies.last&.first ActivityPub::CollectionPresenter.new( type: :unordered, + id: ActivityPub::TagManager.instance.replies_uri_for(object), first: ActivityPub::CollectionPresenter.new( type: :unordered, - page: true, - items: object.self_replies(5).pluck(:uri) + part_of: ActivityPub::TagManager.instance.replies_uri_for(object), + items: replies.map(&:second), + next: last_id ? ActivityPub::TagManager.instance.replies_uri_for(object, page: true, min_id: last_id) : nil ) ) end |