From fbc77eb648bda9add4634c08dbb6af48c3670b5d Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Thu, 9 Jan 2020 00:43:52 +0100 Subject: Add outbox page size parameter --- server/helpers/activitypub.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'server/helpers') diff --git a/server/helpers/activitypub.ts b/server/helpers/activitypub.ts index 735f2d73a..239d8291d 100644 --- a/server/helpers/activitypub.ts +++ b/server/helpers/activitypub.ts @@ -100,7 +100,12 @@ function activityPubContextify (data: T) { } type ActivityPubCollectionPaginationHandler = (start: number, count: number) => Bluebird> | Promise> -async function activityPubCollectionPagination (baseUrl: string, handler: ActivityPubCollectionPaginationHandler, page?: any) { +async function activityPubCollectionPagination ( + baseUrl: string, + handler: ActivityPubCollectionPaginationHandler, + page?: any, + size = ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE +) { if (!page || !validator.isInt(page)) { // We just display the first page URL, we only need the total items const result = await handler(0, 1) @@ -113,7 +118,7 @@ async function activityPubCollectionPagination (baseUrl: string, handler: Activi } } - const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE) + const { start, count } = pageToStartAndCount(page, size) const result = await handler(start, count) let next: string | undefined @@ -123,7 +128,7 @@ async function activityPubCollectionPagination (baseUrl: string, handler: Activi page = parseInt(page, 10) // There are more results - if (result.total > page * ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE) { + if (result.total > page * size) { next = baseUrl + '?page=' + (page + 1) } -- cgit v1.2.3