aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/video-channel.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/video-channel.ts')
-rw-r--r--server/controllers/api/video-channel.ts27
1 files changed, 26 insertions, 1 deletions
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts
index db7602139..534cc8d7b 100644
--- a/server/controllers/api/video-channel.ts
+++ b/server/controllers/api/video-channel.ts
@@ -12,7 +12,8 @@ import {
12 videoChannelsAddValidator, 12 videoChannelsAddValidator,
13 videoChannelsRemoveValidator, 13 videoChannelsRemoveValidator,
14 videoChannelsSortValidator, 14 videoChannelsSortValidator,
15 videoChannelsUpdateValidator 15 videoChannelsUpdateValidator,
16 videoPlaylistsSortValidator
16} from '../../middlewares' 17} from '../../middlewares'
17import { VideoChannelModel } from '../../models/video/video-channel' 18import { VideoChannelModel } from '../../models/video/video-channel'
18import { videoChannelsNameWithHostValidator, videosSortValidator } from '../../middlewares/validators' 19import { videoChannelsNameWithHostValidator, videosSortValidator } from '../../middlewares/validators'
@@ -31,6 +32,7 @@ import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '..
31import { resetSequelizeInstance } from '../../helpers/database-utils' 32import { resetSequelizeInstance } from '../../helpers/database-utils'
32import { UserModel } from '../../models/account/user' 33import { UserModel } from '../../models/account/user'
33import { JobQueue } from '../../lib/job-queue' 34import { JobQueue } from '../../lib/job-queue'
35import { VideoPlaylistModel } from '../../models/video/video-playlist'
34 36
35const auditLogger = auditLoggerFactory('channels') 37const auditLogger = auditLoggerFactory('channels')
36const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) 38const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR })
@@ -77,6 +79,15 @@ videoChannelRouter.get('/:nameWithHost',
77 asyncMiddleware(getVideoChannel) 79 asyncMiddleware(getVideoChannel)
78) 80)
79 81
82videoChannelRouter.get('/:nameWithHost/video-playlists',
83 asyncMiddleware(videoChannelsNameWithHostValidator),
84 paginationValidator,
85 videoPlaylistsSortValidator,
86 setDefaultSort,
87 setDefaultPagination,
88 asyncMiddleware(listVideoChannelPlaylists)
89)
90
80videoChannelRouter.get('/:nameWithHost/videos', 91videoChannelRouter.get('/:nameWithHost/videos',
81 asyncMiddleware(videoChannelsNameWithHostValidator), 92 asyncMiddleware(videoChannelsNameWithHostValidator),
82 paginationValidator, 93 paginationValidator,
@@ -206,6 +217,20 @@ async function getVideoChannel (req: express.Request, res: express.Response, nex
206 return res.json(videoChannelWithVideos.toFormattedJSON()) 217 return res.json(videoChannelWithVideos.toFormattedJSON())
207} 218}
208 219
220async function listVideoChannelPlaylists (req: express.Request, res: express.Response) {
221 const serverActor = await getServerActor()
222
223 const resultList = await VideoPlaylistModel.listForApi({
224 followerActorId: serverActor.id,
225 start: req.query.start,
226 count: req.query.count,
227 sort: req.query.sort,
228 videoChannelId: res.locals.videoChannel.id
229 })
230
231 return res.json(getFormattedObjects(resultList.data, resultList.total))
232}
233
209async function listVideoChannelVideos (req: express.Request, res: express.Response, next: express.NextFunction) { 234async function listVideoChannelVideos (req: express.Request, res: express.Response, next: express.NextFunction) {
210 const videoChannelInstance: VideoChannelModel = res.locals.videoChannel 235 const videoChannelInstance: VideoChannelModel = res.locals.videoChannel
211 const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined 236 const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined