]>
Commit | Line | Data |
---|---|---|
e4f97bab | 1 | import * as express from 'express' |
670e955c | 2 | import * as cors from 'cors' |
8fffe21a | 3 | import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos' |
d6e99e53 | 4 | import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' |
74dc3bca | 5 | import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../../initializers/constants' |
1e7eb25f | 6 | import { buildAnnounceWithVideoAudience, buildLikeActivity } from '../../lib/activitypub/send' |
e251f170 | 7 | import { audiencify, getAudience } from '../../lib/activitypub/audience' |
c48e82b5 | 8 | import { buildCreateActivity } from '../../lib/activitypub/send/send-create' |
96f29c0f C |
9 | import { |
10 | asyncMiddleware, | |
11 | executeIfActivityPub, | |
12 | localAccountValidator, | |
13 | localVideoChannelValidator, | |
1e7eb25f C |
14 | videosCustomGetValidator, |
15 | videosShareValidator | |
96f29c0f | 16 | } from '../../middlewares' |
75ba887d | 17 | import { getAccountVideoRateValidatorFactory, videoCommentGetValidator } from '../../middlewares/validators' |
3fd3ab2d | 18 | import { AccountModel } from '../../models/account/account' |
50d6de9c | 19 | import { ActorFollowModel } from '../../models/activitypub/actor-follow' |
3fd3ab2d | 20 | import { VideoModel } from '../../models/video/video' |
da854ddd | 21 | import { VideoCommentModel } from '../../models/video/video-comment' |
3fd3ab2d | 22 | import { VideoShareModel } from '../../models/video/video-share' |
98d3324d | 23 | import { cacheRoute } from '../../middlewares/cache' |
8fffe21a C |
24 | import { activityPubResponse } from './utils' |
25 | import { AccountVideoRateModel } from '../../models/account/account-video-rate' | |
26 | import { | |
5c6d985f | 27 | getRateUrl, |
8fffe21a C |
28 | getVideoCommentsActivityPubUrl, |
29 | getVideoDislikesActivityPubUrl, | |
30 | getVideoLikesActivityPubUrl, | |
31 | getVideoSharesActivityPubUrl | |
32 | } from '../../lib/activitypub' | |
40e87e9e | 33 | import { VideoCaptionModel } from '../../models/video/video-caption' |
09209296 | 34 | import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } from '../../middlewares/validators/redundancy' |
c48e82b5 | 35 | import { getServerActor } from '../../helpers/utils' |
1e7eb25f | 36 | import { buildDislikeActivity } from '../../lib/activitypub/send/send-dislike' |
418d092a C |
37 | import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists' |
38 | import { VideoPlaylistModel } from '../../models/video/video-playlist' | |
418d092a | 39 | import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' |
2c8776fc | 40 | import { MAccountId, MActorId, MVideoAPWithoutCaption, MVideoId } from '@server/typings/models' |
e4f97bab C |
41 | |
42 | const activityPubClientRouter = express.Router() | |
670e955c | 43 | activityPubClientRouter.use(cors()) |
e4f97bab | 44 | |
2c8776fc C |
45 | // Intercept ActivityPub client requests |
46 | ||
108af661 | 47 | activityPubClientRouter.get('/accounts?/:name', |
e65c0c5b C |
48 | executeIfActivityPub, |
49 | asyncMiddleware(localAccountValidator), | |
50 | accountController | |
e4f97bab | 51 | ) |
7006bc63 | 52 | activityPubClientRouter.get('/accounts?/:name/followers', |
e65c0c5b C |
53 | executeIfActivityPub, |
54 | asyncMiddleware(localAccountValidator), | |
55 | asyncMiddleware(accountFollowersController) | |
e4f97bab | 56 | ) |
7006bc63 | 57 | activityPubClientRouter.get('/accounts?/:name/following', |
e65c0c5b C |
58 | executeIfActivityPub, |
59 | asyncMiddleware(localAccountValidator), | |
60 | asyncMiddleware(accountFollowingController) | |
e4f97bab | 61 | ) |
418d092a | 62 | activityPubClientRouter.get('/accounts?/:name/playlists', |
e65c0c5b C |
63 | executeIfActivityPub, |
64 | asyncMiddleware(localAccountValidator), | |
65 | asyncMiddleware(accountPlaylistsController) | |
418d092a | 66 | ) |
5c6d985f | 67 | activityPubClientRouter.get('/accounts?/:name/likes/:videoId', |
e65c0c5b | 68 | executeIfActivityPub, |
75ba887d C |
69 | asyncMiddleware(getAccountVideoRateValidatorFactory('like')), |
70 | getAccountVideoRateFactory('like') | |
5c6d985f C |
71 | ) |
72 | activityPubClientRouter.get('/accounts?/:name/dislikes/:videoId', | |
e65c0c5b | 73 | executeIfActivityPub, |
75ba887d C |
74 | asyncMiddleware(getAccountVideoRateValidatorFactory('dislike')), |
75 | getAccountVideoRateFactory('dislike') | |
5c6d985f | 76 | ) |
e4f97bab | 77 | |
20494f12 | 78 | activityPubClientRouter.get('/videos/watch/:id', |
e65c0c5b | 79 | executeIfActivityPub, |
f2f0eda5 | 80 | asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.ACTIVITY_PUB.VIDEOS)), |
e65c0c5b C |
81 | asyncMiddleware(videosCustomGetValidator('only-video-with-rights')), |
82 | asyncMiddleware(videoController) | |
4e50b6a1 | 83 | ) |
296c0905 | 84 | activityPubClientRouter.get('/videos/watch/:id/activity', |
e65c0c5b C |
85 | executeIfActivityPub, |
86 | asyncMiddleware(videosCustomGetValidator('only-video-with-rights')), | |
87 | asyncMiddleware(videoController) | |
296c0905 | 88 | ) |
46531a0a | 89 | activityPubClientRouter.get('/videos/watch/:id/announces', |
e65c0c5b | 90 | executeIfActivityPub, |
7eba5e1f | 91 | asyncMiddleware(videosCustomGetValidator('only-immutable-attributes')), |
e65c0c5b | 92 | asyncMiddleware(videoAnnouncesController) |
46531a0a | 93 | ) |
5c6d985f | 94 | activityPubClientRouter.get('/videos/watch/:id/announces/:actorId', |
e65c0c5b C |
95 | executeIfActivityPub, |
96 | asyncMiddleware(videosShareValidator), | |
97 | asyncMiddleware(videoAnnounceController) | |
20494f12 | 98 | ) |
46531a0a | 99 | activityPubClientRouter.get('/videos/watch/:id/likes', |
e65c0c5b | 100 | executeIfActivityPub, |
7eba5e1f | 101 | asyncMiddleware(videosCustomGetValidator('only-immutable-attributes')), |
e65c0c5b | 102 | asyncMiddleware(videoLikesController) |
46531a0a C |
103 | ) |
104 | activityPubClientRouter.get('/videos/watch/:id/dislikes', | |
e65c0c5b | 105 | executeIfActivityPub, |
7eba5e1f | 106 | asyncMiddleware(videosCustomGetValidator('only-immutable-attributes')), |
e65c0c5b | 107 | asyncMiddleware(videoDislikesController) |
46531a0a C |
108 | ) |
109 | activityPubClientRouter.get('/videos/watch/:id/comments', | |
e65c0c5b | 110 | executeIfActivityPub, |
7eba5e1f | 111 | asyncMiddleware(videosCustomGetValidator('only-immutable-attributes')), |
e65c0c5b | 112 | asyncMiddleware(videoCommentsController) |
46531a0a | 113 | ) |
da854ddd | 114 | activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId', |
e65c0c5b C |
115 | executeIfActivityPub, |
116 | asyncMiddleware(videoCommentGetValidator), | |
117 | asyncMiddleware(videoCommentController) | |
da854ddd | 118 | ) |
296c0905 | 119 | activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId/activity', |
e65c0c5b C |
120 | executeIfActivityPub, |
121 | asyncMiddleware(videoCommentGetValidator), | |
122 | asyncMiddleware(videoCommentController) | |
296c0905 | 123 | ) |
da854ddd | 124 | |
8a19bee1 | 125 | activityPubClientRouter.get('/video-channels/:name', |
e65c0c5b C |
126 | executeIfActivityPub, |
127 | asyncMiddleware(localVideoChannelValidator), | |
a1587156 | 128 | videoChannelController |
20494f12 | 129 | ) |
8a19bee1 | 130 | activityPubClientRouter.get('/video-channels/:name/followers', |
e65c0c5b C |
131 | executeIfActivityPub, |
132 | asyncMiddleware(localVideoChannelValidator), | |
133 | asyncMiddleware(videoChannelFollowersController) | |
7006bc63 | 134 | ) |
8a19bee1 | 135 | activityPubClientRouter.get('/video-channels/:name/following', |
e65c0c5b C |
136 | executeIfActivityPub, |
137 | asyncMiddleware(localVideoChannelValidator), | |
138 | asyncMiddleware(videoChannelFollowingController) | |
7006bc63 | 139 | ) |
20494f12 | 140 | |
c48e82b5 | 141 | activityPubClientRouter.get('/redundancy/videos/:videoId/:resolution([0-9]+)(-:fps([0-9]+))?', |
e65c0c5b C |
142 | executeIfActivityPub, |
143 | asyncMiddleware(videoFileRedundancyGetValidator), | |
144 | asyncMiddleware(videoRedundancyController) | |
09209296 | 145 | ) |
9c6ca37f | 146 | activityPubClientRouter.get('/redundancy/streaming-playlists/:streamingPlaylistType/:videoId', |
e65c0c5b C |
147 | executeIfActivityPub, |
148 | asyncMiddleware(videoPlaylistRedundancyGetValidator), | |
149 | asyncMiddleware(videoRedundancyController) | |
c48e82b5 C |
150 | ) |
151 | ||
418d092a | 152 | activityPubClientRouter.get('/video-playlists/:playlistId', |
e65c0c5b | 153 | executeIfActivityPub, |
453e83ea | 154 | asyncMiddleware(videoPlaylistsGetValidator('all')), |
e65c0c5b | 155 | asyncMiddleware(videoPlaylistController) |
418d092a C |
156 | ) |
157 | activityPubClientRouter.get('/video-playlists/:playlistId/:videoId', | |
e65c0c5b C |
158 | executeIfActivityPub, |
159 | asyncMiddleware(videoPlaylistElementAPGetValidator), | |
a1587156 | 160 | videoPlaylistElementController |
418d092a C |
161 | ) |
162 | ||
e4f97bab C |
163 | // --------------------------------------------------------------------------- |
164 | ||
165 | export { | |
166 | activityPubClientRouter | |
167 | } | |
168 | ||
169 | // --------------------------------------------------------------------------- | |
170 | ||
418d092a | 171 | function accountController (req: express.Request, res: express.Response) { |
dae86118 | 172 | const account = res.locals.account |
e4f97bab | 173 | |
4b8f09fa | 174 | return activityPubResponse(activityPubContextify(account.toActivityPubObject()), res) |
e4f97bab C |
175 | } |
176 | ||
418d092a | 177 | async function accountFollowersController (req: express.Request, res: express.Response) { |
dae86118 | 178 | const account = res.locals.account |
7006bc63 | 179 | const activityPubResult = await actorFollowers(req, account.Actor) |
e4f97bab | 180 | |
4b8f09fa | 181 | return activityPubResponse(activityPubContextify(activityPubResult), res) |
e4f97bab C |
182 | } |
183 | ||
418d092a | 184 | async function accountFollowingController (req: express.Request, res: express.Response) { |
dae86118 | 185 | const account = res.locals.account |
7006bc63 | 186 | const activityPubResult = await actorFollowing(req, account.Actor) |
e4f97bab | 187 | |
4b8f09fa | 188 | return activityPubResponse(activityPubContextify(activityPubResult), res) |
e4f97bab | 189 | } |
20494f12 | 190 | |
418d092a | 191 | async function accountPlaylistsController (req: express.Request, res: express.Response) { |
dae86118 | 192 | const account = res.locals.account |
418d092a C |
193 | const activityPubResult = await actorPlaylists(req, account) |
194 | ||
195 | return activityPubResponse(activityPubContextify(activityPubResult), res) | |
196 | } | |
197 | ||
75ba887d | 198 | function getAccountVideoRateFactory (rateType: VideoRateType) { |
5c6d985f | 199 | return (req: express.Request, res: express.Response) => { |
dae86118 | 200 | const accountVideoRate = res.locals.accountVideoRate |
5c6d985f C |
201 | |
202 | const byActor = accountVideoRate.Account.Actor | |
203 | const url = getRateUrl(rateType, byActor, accountVideoRate.Video) | |
204 | const APObject = rateType === 'like' | |
205 | ? buildLikeActivity(url, byActor, accountVideoRate.Video) | |
1e7eb25f | 206 | : buildDislikeActivity(url, byActor, accountVideoRate.Video) |
5c6d985f C |
207 | |
208 | return activityPubResponse(activityPubContextify(APObject), res) | |
209 | } | |
210 | } | |
211 | ||
1a8dd4da | 212 | async function videoController (req: express.Request, res: express.Response) { |
09209296 | 213 | // We need more attributes |
453e83ea | 214 | const video = await VideoModel.loadForGetAPI({ id: res.locals.onlyVideoWithRights.id }) as MVideoAPWithoutCaption |
20494f12 | 215 | |
6dd9de95 | 216 | if (video.url.startsWith(WEBSERVER.URL) === false) return res.redirect(video.url) |
8d1fa36a | 217 | |
40e87e9e | 218 | // We need captions to render AP object |
453e83ea | 219 | const captions = await VideoCaptionModel.listVideoCaptions(video.id) |
b5fecbf4 | 220 | const videoWithCaptions = Object.assign(video, { VideoCaptions: captions }) |
40e87e9e | 221 | |
453e83ea C |
222 | const audience = getAudience(videoWithCaptions.VideoChannel.Account.Actor, videoWithCaptions.privacy === VideoPrivacy.PUBLIC) |
223 | const videoObject = audiencify(videoWithCaptions.toActivityPubObject(), audience) | |
2ccaeeb3 | 224 | |
296c0905 | 225 | if (req.path.endsWith('/activity')) { |
453e83ea | 226 | const data = buildCreateActivity(videoWithCaptions.url, video.VideoChannel.Account.Actor, videoObject, audience) |
4b8f09fa | 227 | return activityPubResponse(activityPubContextify(data), res) |
296c0905 C |
228 | } |
229 | ||
4b8f09fa | 230 | return activityPubResponse(activityPubContextify(videoObject), res) |
20494f12 C |
231 | } |
232 | ||
1a8dd4da | 233 | async function videoAnnounceController (req: express.Request, res: express.Response) { |
dae86118 | 234 | const share = res.locals.videoShare |
8d1fa36a | 235 | |
6dd9de95 | 236 | if (share.url.startsWith(WEBSERVER.URL) === false) return res.redirect(share.url) |
8d1fa36a | 237 | |
453e83ea | 238 | const { activity } = await buildAnnounceWithVideoAudience(share.Actor, share, res.locals.videoAll, undefined) |
4e50b6a1 | 239 | |
598edb8a | 240 | return activityPubResponse(activityPubContextify(activity, 'Announce'), res) |
4e50b6a1 C |
241 | } |
242 | ||
1a8dd4da | 243 | async function videoAnnouncesController (req: express.Request, res: express.Response) { |
7eba5e1f | 244 | const video = res.locals.onlyImmutableVideo |
46531a0a | 245 | |
8fffe21a C |
246 | const handler = async (start: number, count: number) => { |
247 | const result = await VideoShareModel.listAndCountByVideoId(video.id, start, count) | |
248 | return { | |
249 | total: result.count, | |
250 | data: result.rows.map(r => r.url) | |
251 | } | |
252 | } | |
253 | const json = await activityPubCollectionPagination(getVideoSharesActivityPubUrl(video), handler, req.query.page) | |
46531a0a | 254 | |
8fffe21a | 255 | return activityPubResponse(activityPubContextify(json), res) |
46531a0a C |
256 | } |
257 | ||
1a8dd4da | 258 | async function videoLikesController (req: express.Request, res: express.Response) { |
7eba5e1f | 259 | const video = res.locals.onlyImmutableVideo |
8fffe21a | 260 | const json = await videoRates(req, 'like', video, getVideoLikesActivityPubUrl(video)) |
46531a0a | 261 | |
8fffe21a | 262 | return activityPubResponse(activityPubContextify(json), res) |
46531a0a C |
263 | } |
264 | ||
1a8dd4da | 265 | async function videoDislikesController (req: express.Request, res: express.Response) { |
7eba5e1f | 266 | const video = res.locals.onlyImmutableVideo |
8fffe21a | 267 | const json = await videoRates(req, 'dislike', video, getVideoDislikesActivityPubUrl(video)) |
46531a0a | 268 | |
8fffe21a | 269 | return activityPubResponse(activityPubContextify(json), res) |
46531a0a C |
270 | } |
271 | ||
1a8dd4da | 272 | async function videoCommentsController (req: express.Request, res: express.Response) { |
7eba5e1f | 273 | const video = res.locals.onlyImmutableVideo |
46531a0a | 274 | |
8fffe21a C |
275 | const handler = async (start: number, count: number) => { |
276 | const result = await VideoCommentModel.listAndCountByVideoId(video.id, start, count) | |
277 | return { | |
278 | total: result.count, | |
279 | data: result.rows.map(r => r.url) | |
280 | } | |
281 | } | |
282 | const json = await activityPubCollectionPagination(getVideoCommentsActivityPubUrl(video), handler, req.query.page) | |
46531a0a | 283 | |
8fffe21a | 284 | return activityPubResponse(activityPubContextify(json), res) |
46531a0a C |
285 | } |
286 | ||
a1587156 | 287 | function videoChannelController (req: express.Request, res: express.Response) { |
dae86118 | 288 | const videoChannel = res.locals.videoChannel |
20494f12 | 289 | |
4b8f09fa | 290 | return activityPubResponse(activityPubContextify(videoChannel.toActivityPubObject()), res) |
20494f12 | 291 | } |
da854ddd | 292 | |
1a8dd4da | 293 | async function videoChannelFollowersController (req: express.Request, res: express.Response) { |
dae86118 | 294 | const videoChannel = res.locals.videoChannel |
7006bc63 C |
295 | const activityPubResult = await actorFollowers(req, videoChannel.Actor) |
296 | ||
4b8f09fa | 297 | return activityPubResponse(activityPubContextify(activityPubResult), res) |
7006bc63 C |
298 | } |
299 | ||
1a8dd4da | 300 | async function videoChannelFollowingController (req: express.Request, res: express.Response) { |
dae86118 | 301 | const videoChannel = res.locals.videoChannel |
7006bc63 C |
302 | const activityPubResult = await actorFollowing(req, videoChannel.Actor) |
303 | ||
4b8f09fa | 304 | return activityPubResponse(activityPubContextify(activityPubResult), res) |
7006bc63 C |
305 | } |
306 | ||
1a8dd4da | 307 | async function videoCommentController (req: express.Request, res: express.Response) { |
453e83ea | 308 | const videoComment = res.locals.videoCommentFull |
da854ddd | 309 | |
6dd9de95 | 310 | if (videoComment.url.startsWith(WEBSERVER.URL) === false) return res.redirect(videoComment.url) |
8d1fa36a | 311 | |
d7e70384 | 312 | const threadParentComments = await VideoCommentModel.listThreadParentComments(videoComment, undefined) |
d6e99e53 | 313 | const isPublic = true // Comments are always public |
69222afa | 314 | let videoCommentObject = videoComment.toActivityPubObject(threadParentComments) |
d6e99e53 | 315 | |
69222afa JM |
316 | if (videoComment.Account) { |
317 | const audience = getAudience(videoComment.Account.Actor, isPublic) | |
318 | videoCommentObject = audiencify(videoCommentObject, audience) | |
d6e99e53 | 319 | |
69222afa JM |
320 | if (req.path.endsWith('/activity')) { |
321 | const data = buildCreateActivity(videoComment.url, videoComment.Account.Actor, videoCommentObject, audience) | |
322 | return activityPubResponse(activityPubContextify(data), res) | |
323 | } | |
296c0905 C |
324 | } |
325 | ||
4b8f09fa | 326 | return activityPubResponse(activityPubContextify(videoCommentObject), res) |
da854ddd | 327 | } |
7006bc63 | 328 | |
c48e82b5 | 329 | async function videoRedundancyController (req: express.Request, res: express.Response) { |
dae86118 | 330 | const videoRedundancy = res.locals.videoRedundancy |
6dd9de95 | 331 | if (videoRedundancy.url.startsWith(WEBSERVER.URL) === false) return res.redirect(videoRedundancy.url) |
8d1fa36a | 332 | |
c48e82b5 C |
333 | const serverActor = await getServerActor() |
334 | ||
335 | const audience = getAudience(serverActor) | |
336 | const object = audiencify(videoRedundancy.toActivityPubObject(), audience) | |
337 | ||
338 | if (req.path.endsWith('/activity')) { | |
339 | const data = buildCreateActivity(videoRedundancy.url, serverActor, object, audience) | |
084a2cd0 | 340 | return activityPubResponse(activityPubContextify(data, 'CacheFile'), res) |
c48e82b5 C |
341 | } |
342 | ||
084a2cd0 | 343 | return activityPubResponse(activityPubContextify(object, 'CacheFile'), res) |
c48e82b5 C |
344 | } |
345 | ||
418d092a | 346 | async function videoPlaylistController (req: express.Request, res: express.Response) { |
453e83ea | 347 | const playlist = res.locals.videoPlaylistFull |
418d092a | 348 | |
df0b219d C |
349 | // We need more attributes |
350 | playlist.OwnerAccount = await AccountModel.load(playlist.ownerAccountId) | |
351 | ||
352 | const json = await playlist.toActivityPubObject(req.query.page, null) | |
418d092a C |
353 | const audience = getAudience(playlist.OwnerAccount.Actor, playlist.privacy === VideoPlaylistPrivacy.PUBLIC) |
354 | const object = audiencify(json, audience) | |
355 | ||
356 | return activityPubResponse(activityPubContextify(object), res) | |
357 | } | |
358 | ||
a1587156 | 359 | function videoPlaylistElementController (req: express.Request, res: express.Response) { |
b5fecbf4 | 360 | const videoPlaylistElement = res.locals.videoPlaylistElementAP |
418d092a C |
361 | |
362 | const json = videoPlaylistElement.toActivityPubObject() | |
363 | return activityPubResponse(activityPubContextify(json), res) | |
364 | } | |
365 | ||
7006bc63 C |
366 | // --------------------------------------------------------------------------- |
367 | ||
453e83ea | 368 | async function actorFollowing (req: express.Request, actor: MActorId) { |
8fffe21a C |
369 | const handler = (start: number, count: number) => { |
370 | return ActorFollowModel.listAcceptedFollowingUrlsForApi([ actor.id ], undefined, start, count) | |
371 | } | |
7006bc63 | 372 | |
6dd9de95 | 373 | return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page) |
7006bc63 C |
374 | } |
375 | ||
453e83ea | 376 | async function actorFollowers (req: express.Request, actor: MActorId) { |
8fffe21a | 377 | const handler = (start: number, count: number) => { |
418d092a C |
378 | return ActorFollowModel.listAcceptedFollowerUrlsForAP([ actor.id ], undefined, start, count) |
379 | } | |
380 | ||
6dd9de95 | 381 | return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page) |
418d092a C |
382 | } |
383 | ||
453e83ea | 384 | async function actorPlaylists (req: express.Request, account: MAccountId) { |
418d092a | 385 | const handler = (start: number, count: number) => { |
0b16f5f2 | 386 | return VideoPlaylistModel.listPublicUrlsOfForAP(account.id, start, count) |
8fffe21a | 387 | } |
7006bc63 | 388 | |
6dd9de95 | 389 | return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page) |
7006bc63 | 390 | } |
4b8f09fa | 391 | |
7eba5e1f | 392 | function videoRates (req: express.Request, rateType: VideoRateType, video: MVideoId, url: string) { |
8fffe21a C |
393 | const handler = async (start: number, count: number) => { |
394 | const result = await AccountVideoRateModel.listAndCountAccountUrlsByVideoId(rateType, video.id, start, count) | |
395 | return { | |
396 | total: result.count, | |
5c6d985f | 397 | data: result.rows.map(r => r.url) |
8fffe21a C |
398 | } |
399 | } | |
400 | return activityPubCollectionPagination(url, handler, req.query.page) | |
4b8f09fa | 401 | } |