diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2018-05-04 19:19:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-04 19:19:11 +0200 |
commit | 2c1f7b2ece96c724f6230352974d4282ac51dfd5 (patch) | |
tree | 4d23240183d1568391150440c3d78bf97c1f03b3 /app/serializers | |
parent | d181aad03387b87b5cb82867f8efb3b635093f11 (diff) |
Better pagination for ActivityPub outbox (#7356)
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/activitypub/collection_serializer.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/app/serializers/activitypub/collection_serializer.rb b/app/serializers/activitypub/collection_serializer.rb index 1ae492945..e8960131b 100644 --- a/app/serializers/activitypub/collection_serializer.rb +++ b/app/serializers/activitypub/collection_serializer.rb @@ -7,12 +7,14 @@ class ActivityPub::CollectionSerializer < ActiveModel::Serializer super end - attributes :id, :type, :total_items + attributes :id, :type + attribute :total_items, if: -> { object.size.present? } attribute :next, if: -> { object.next.present? } attribute :prev, if: -> { object.prev.present? } attribute :part_of, if: -> { object.part_of.present? } has_one :first, if: -> { object.first.present? } + has_one :last, if: -> { object.last.present? } has_many :items, key: :items, if: -> { (!object.items.nil? || page?) && !ordered? } has_many :items, key: :ordered_items, if: -> { (!object.items.nil? || page?) && ordered? } |