diff options
author | buoyantair <buoyantair@protonmail.com> | 2018-11-18 21:55:52 +0530 |
---|---|---|
committer | buoyantair <buoyantair@protonmail.com> | 2018-11-18 21:55:52 +0530 |
commit | b9f234371bfaf0d9cfa81e02fcea92cac1f9ae13 (patch) | |
tree | dcdf451ac431ec7953bee58e814f642d1c370d1b /server/helpers/activitypub.ts | |
parent | 92e07c3b5d9dbf2febedb1b5b87ec676eb6d1ac8 (diff) | |
parent | 9d0b856e930ee1c676d16a56408a3e4a18f8f978 (diff) | |
download | PeerTube-b9f234371bfaf0d9cfa81e02fcea92cac1f9ae13.tar.gz PeerTube-b9f234371bfaf0d9cfa81e02fcea92cac1f9ae13.tar.zst PeerTube-b9f234371bfaf0d9cfa81e02fcea92cac1f9ae13.zip |
Merge branch 'develop' of https://github.com/Chocobozzz/PeerTube into move-utils-to-shared
Diffstat (limited to 'server/helpers/activitypub.ts')
-rw-r--r-- | server/helpers/activitypub.ts | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/server/helpers/activitypub.ts b/server/helpers/activitypub.ts index 4bf6e387d..bcbd9be59 100644 --- a/server/helpers/activitypub.ts +++ b/server/helpers/activitypub.ts | |||
@@ -57,16 +57,16 @@ function activityPubContextify <T> (data: T) { | |||
57 | } | 57 | } |
58 | 58 | ||
59 | type ActivityPubCollectionPaginationHandler = (start: number, count: number) => Bluebird<ResultList<any>> | Promise<ResultList<any>> | 59 | type ActivityPubCollectionPaginationHandler = (start: number, count: number) => Bluebird<ResultList<any>> | Promise<ResultList<any>> |
60 | async function activityPubCollectionPagination (url: string, handler: ActivityPubCollectionPaginationHandler, page?: any) { | 60 | async function activityPubCollectionPagination (baseUrl: string, handler: ActivityPubCollectionPaginationHandler, page?: any) { |
61 | if (!page || !validator.isInt(page)) { | 61 | if (!page || !validator.isInt(page)) { |
62 | // We just display the first page URL, we only need the total items | 62 | // We just display the first page URL, we only need the total items |
63 | const result = await handler(0, 1) | 63 | const result = await handler(0, 1) |
64 | 64 | ||
65 | return { | 65 | return { |
66 | id: url, | 66 | id: baseUrl, |
67 | type: 'OrderedCollection', | 67 | type: 'OrderedCollection', |
68 | totalItems: result.total, | 68 | totalItems: result.total, |
69 | first: url + '?page=1' | 69 | first: baseUrl + '?page=1' |
70 | } | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
@@ -81,19 +81,19 @@ async function activityPubCollectionPagination (url: string, handler: ActivityPu | |||
81 | 81 | ||
82 | // There are more results | 82 | // There are more results |
83 | if (result.total > page * ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE) { | 83 | if (result.total > page * ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE) { |
84 | next = url + '?page=' + (page + 1) | 84 | next = baseUrl + '?page=' + (page + 1) |
85 | } | 85 | } |
86 | 86 | ||
87 | if (page > 1) { | 87 | if (page > 1) { |
88 | prev = url + '?page=' + (page - 1) | 88 | prev = baseUrl + '?page=' + (page - 1) |
89 | } | 89 | } |
90 | 90 | ||
91 | return { | 91 | return { |
92 | id: url + '?page=' + page, | 92 | id: baseUrl + '?page=' + page, |
93 | type: 'OrderedCollectionPage', | 93 | type: 'OrderedCollectionPage', |
94 | prev, | 94 | prev, |
95 | next, | 95 | next, |
96 | partOf: url, | 96 | partOf: baseUrl, |
97 | orderedItems: result.data, | 97 | orderedItems: result.data, |
98 | totalItems: result.total | 98 | totalItems: result.total |
99 | } | 99 | } |