aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/controllers/activitypub/client.ts20
-rw-r--r--server/models/video/video-playlist.ts20
2 files changed, 31 insertions, 9 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'
35import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists' 35import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists'
36import { VideoPlaylistModel } from '../../models/video/video-playlist' 36import { VideoPlaylistModel } from '../../models/video/video-playlist'
37import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' 37import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model'
38import { MAccountId, MActorId, MVideoAPWithoutCaption, MVideoId } from '@server/typings/models' 38import { MAccountId, MActorId, MVideoAPWithoutCaption, MVideoId, MChannelId } from '@server/typings/models'
39import { getServerActor } from '@server/models/application/application' 39import { getServerActor } from '@server/models/application/application'
40import { getRateUrl } from '@server/lib/activitypub/video-rates' 40import { 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)
140activityPubClientRouter.get('/video-channels/:name/playlists',
141 executeIfActivityPub,
142 asyncMiddleware(localVideoChannelValidator),
143 asyncMiddleware(videoChannelPlaylistsController)
144)
140 145
141activityPubClientRouter.get('/redundancy/videos/:videoId/:resolution([0-9]+)(-:fps([0-9]+))?', 146activityPubClientRouter.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
191async function accountPlaylistsController (req: express.Request, res: express.Response) { 196async 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
203async 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
384async function actorPlaylists (req: express.Request, account: MAccountId) { 396async 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)
diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.ts
index b9b95e067..d66518c9f 100644
--- a/server/models/video/video-playlist.ts
+++ b/server/models/video/video-playlist.ts
@@ -53,6 +53,7 @@ import {
53 MVideoPlaylistIdWithElements 53 MVideoPlaylistIdWithElements
54} from '../../typings/models/video/video-playlist' 54} from '../../typings/models/video/video-playlist'
55import { MThumbnail } from '../../typings/models/video/thumbnail' 55import { MThumbnail } from '../../typings/models/video/thumbnail'
56import { MAccountId, MChannelId } from '@server/typings/models'
56 57
57enum ScopeNames { 58enum ScopeNames {
58 AVAILABLE_FOR_LIST = 'AVAILABLE_FOR_LIST', 59 AVAILABLE_FOR_LIST = 'AVAILABLE_FOR_LIST',
@@ -340,15 +341,24 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> {
340 }) 341 })
341 } 342 }
342 343
343 static listPublicUrlsOfForAP (accountId: number, start: number, count: number) { 344 static listPublicUrlsOfForAP (options: { account?: MAccountId, channel?: MChannelId }, start: number, count: number) {
345 const where = {
346 privacy: VideoPlaylistPrivacy.PUBLIC
347 }
348
349 if (options.account) {
350 Object.assign(where, { ownerAccountId: options.account.id })
351 }
352
353 if (options.channel) {
354 Object.assign(where, { videoChannelId: options.channel.id })
355 }
356
344 const query = { 357 const query = {
345 attributes: [ 'url' ], 358 attributes: [ 'url' ],
346 offset: start, 359 offset: start,
347 limit: count, 360 limit: count,
348 where: { 361 where
349 ownerAccountId: accountId,
350 privacy: VideoPlaylistPrivacy.PUBLIC
351 }
352 } 362 }
353 363
354 return VideoPlaylistModel.findAndCountAll(query) 364 return VideoPlaylistModel.findAndCountAll(query)