diff options
author | Chocobozzz <me@florianbigard.com> | 2020-05-13 14:49:11 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-05-13 14:49:11 +0200 |
commit | 7405b6ba897dbce1b4fd50c92174f1df5ac15adc (patch) | |
tree | 88816a1e713801e06ec50fb98c4bb3d05b612d1c /server/controllers/activitypub/client.ts | |
parent | 63748ad00517022de1d89f9dc3003135b2f10629 (diff) | |
download | PeerTube-7405b6ba897dbce1b4fd50c92174f1df5ac15adc.tar.gz PeerTube-7405b6ba897dbce1b4fd50c92174f1df5ac15adc.tar.zst PeerTube-7405b6ba897dbce1b4fd50c92174f1df5ac15adc.zip |
Add missing channel playlists AP endpoint
Diffstat (limited to 'server/controllers/activitypub/client.ts')
-rw-r--r-- | server/controllers/activitypub/client.ts | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts index e44f1c6ab..f94abf808 100644 --- a/server/controllers/activitypub/client.ts +++ b/server/controllers/activitypub/client.ts | |||
@@ -35,7 +35,7 @@ import { buildDislikeActivity } from '../../lib/activitypub/send/send-dislike' | |||
35 | import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists' | 35 | import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists' |
36 | import { VideoPlaylistModel } from '../../models/video/video-playlist' | 36 | import { VideoPlaylistModel } from '../../models/video/video-playlist' |
37 | import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' | 37 | import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' |
38 | import { MAccountId, MActorId, MVideoAPWithoutCaption, MVideoId } from '@server/typings/models' | 38 | import { MAccountId, MActorId, MVideoAPWithoutCaption, MVideoId, MChannelId } from '@server/typings/models' |
39 | import { getServerActor } from '@server/models/application/application' | 39 | import { getServerActor } from '@server/models/application/application' |
40 | import { getRateUrl } from '@server/lib/activitypub/video-rates' | 40 | import { getRateUrl } from '@server/lib/activitypub/video-rates' |
41 | 41 | ||
@@ -137,6 +137,11 @@ activityPubClientRouter.get('/video-channels/:name/following', | |||
137 | asyncMiddleware(localVideoChannelValidator), | 137 | asyncMiddleware(localVideoChannelValidator), |
138 | asyncMiddleware(videoChannelFollowingController) | 138 | asyncMiddleware(videoChannelFollowingController) |
139 | ) | 139 | ) |
140 | activityPubClientRouter.get('/video-channels/:name/playlists', | ||
141 | executeIfActivityPub, | ||
142 | asyncMiddleware(localVideoChannelValidator), | ||
143 | asyncMiddleware(videoChannelPlaylistsController) | ||
144 | ) | ||
140 | 145 | ||
141 | activityPubClientRouter.get('/redundancy/videos/:videoId/:resolution([0-9]+)(-:fps([0-9]+))?', | 146 | activityPubClientRouter.get('/redundancy/videos/:videoId/:resolution([0-9]+)(-:fps([0-9]+))?', |
142 | executeIfActivityPub, | 147 | executeIfActivityPub, |
@@ -190,7 +195,14 @@ async function accountFollowingController (req: express.Request, res: express.Re | |||
190 | 195 | ||
191 | async function accountPlaylistsController (req: express.Request, res: express.Response) { | 196 | async function accountPlaylistsController (req: express.Request, res: express.Response) { |
192 | const account = res.locals.account | 197 | const account = res.locals.account |
193 | const activityPubResult = await actorPlaylists(req, account) | 198 | const activityPubResult = await actorPlaylists(req, { account }) |
199 | |||
200 | return activityPubResponse(activityPubContextify(activityPubResult), res) | ||
201 | } | ||
202 | |||
203 | async function videoChannelPlaylistsController (req: express.Request, res: express.Response) { | ||
204 | const channel = res.locals.videoChannel | ||
205 | const activityPubResult = await actorPlaylists(req, { channel }) | ||
194 | 206 | ||
195 | return activityPubResponse(activityPubContextify(activityPubResult), res) | 207 | return activityPubResponse(activityPubContextify(activityPubResult), res) |
196 | } | 208 | } |
@@ -381,9 +393,9 @@ async function actorFollowers (req: express.Request, actor: MActorId) { | |||
381 | return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page) | 393 | return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page) |
382 | } | 394 | } |
383 | 395 | ||
384 | async function actorPlaylists (req: express.Request, account: MAccountId) { | 396 | async function actorPlaylists (req: express.Request, options: { account: MAccountId } | { channel: MChannelId }) { |
385 | const handler = (start: number, count: number) => { | 397 | const handler = (start: number, count: number) => { |
386 | return VideoPlaylistModel.listPublicUrlsOfForAP(account.id, start, count) | 398 | return VideoPlaylistModel.listPublicUrlsOfForAP(options, start, count) |
387 | } | 399 | } |
388 | 400 | ||
389 | return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page) | 401 | return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page) |