diff options
Diffstat (limited to 'server/controllers/api/video-channel.ts')
-rw-r--r-- | server/controllers/api/video-channel.ts | 27 |
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' |
17 | import { VideoChannelModel } from '../../models/video/video-channel' | 18 | import { VideoChannelModel } from '../../models/video/video-channel' |
18 | import { videoChannelsNameWithHostValidator, videosSortValidator } from '../../middlewares/validators' | 19 | import { videoChannelsNameWithHostValidator, videosSortValidator } from '../../middlewares/validators' |
@@ -31,6 +32,7 @@ import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '.. | |||
31 | import { resetSequelizeInstance } from '../../helpers/database-utils' | 32 | import { resetSequelizeInstance } from '../../helpers/database-utils' |
32 | import { UserModel } from '../../models/account/user' | 33 | import { UserModel } from '../../models/account/user' |
33 | import { JobQueue } from '../../lib/job-queue' | 34 | import { JobQueue } from '../../lib/job-queue' |
35 | import { VideoPlaylistModel } from '../../models/video/video-playlist' | ||
34 | 36 | ||
35 | const auditLogger = auditLoggerFactory('channels') | 37 | const auditLogger = auditLoggerFactory('channels') |
36 | const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) | 38 | const 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 | ||
82 | videoChannelRouter.get('/:nameWithHost/video-playlists', | ||
83 | asyncMiddleware(videoChannelsNameWithHostValidator), | ||
84 | paginationValidator, | ||
85 | videoPlaylistsSortValidator, | ||
86 | setDefaultSort, | ||
87 | setDefaultPagination, | ||
88 | asyncMiddleware(listVideoChannelPlaylists) | ||
89 | ) | ||
90 | |||
80 | videoChannelRouter.get('/:nameWithHost/videos', | 91 | videoChannelRouter.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 | ||
220 | async 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 | |||
209 | async function listVideoChannelVideos (req: express.Request, res: express.Response, next: express.NextFunction) { | 234 | async 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 |