aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/activitypub.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/activitypub.ts')
-rw-r--r--server/helpers/activitypub.ts11
1 files changed, 8 insertions, 3 deletions
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 <T> (data: T) {
100} 100}
101 101
102type ActivityPubCollectionPaginationHandler = (start: number, count: number) => Bluebird<ResultList<any>> | Promise<ResultList<any>> 102type ActivityPubCollectionPaginationHandler = (start: number, count: number) => Bluebird<ResultList<any>> | Promise<ResultList<any>>
103async function activityPubCollectionPagination (baseUrl: string, handler: ActivityPubCollectionPaginationHandler, page?: any) { 103async function activityPubCollectionPagination (
104 baseUrl: string,
105 handler: ActivityPubCollectionPaginationHandler,
106 page?: any,
107 size = ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE
108) {
104 if (!page || !validator.isInt(page)) { 109 if (!page || !validator.isInt(page)) {
105 // We just display the first page URL, we only need the total items 110 // We just display the first page URL, we only need the total items
106 const result = await handler(0, 1) 111 const result = await handler(0, 1)
@@ -113,7 +118,7 @@ async function activityPubCollectionPagination (baseUrl: string, handler: Activi
113 } 118 }
114 } 119 }
115 120
116 const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE) 121 const { start, count } = pageToStartAndCount(page, size)
117 const result = await handler(start, count) 122 const result = await handler(start, count)
118 123
119 let next: string | undefined 124 let next: string | undefined
@@ -123,7 +128,7 @@ async function activityPubCollectionPagination (baseUrl: string, handler: Activi
123 page = parseInt(page, 10) 128 page = parseInt(page, 10)
124 129
125 // There are more results 130 // There are more results
126 if (result.total > page * ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE) { 131 if (result.total > page * size) {
127 next = baseUrl + '?page=' + (page + 1) 132 next = baseUrl + '?page=' + (page + 1)
128 } 133 }
129 134