diff options
-rw-r--r-- | server/controllers/activitypub/client.ts | 20 | ||||
-rw-r--r-- | server/models/video/video-playlist.ts | 20 |
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' | |||
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) |
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' |
55 | import { MThumbnail } from '../../typings/models/video/thumbnail' | 55 | import { MThumbnail } from '../../typings/models/video/thumbnail' |
56 | import { MAccountId, MChannelId } from '@server/typings/models' | ||
56 | 57 | ||
57 | enum ScopeNames { | 58 | enum 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) |