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.ts28
1 files changed, 28 insertions, 0 deletions
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts
index 6b33e894d..89c7181bd 100644
--- a/server/controllers/api/video-channel.ts
+++ b/server/controllers/api/video-channel.ts
@@ -36,7 +36,9 @@ import {
36 videoPlaylistsSortValidator 36 videoPlaylistsSortValidator
37} from '../../middlewares' 37} from '../../middlewares'
38import { 38import {
39 ensureChannelOwnerCanUpload,
39 ensureIsLocalChannel, 40 ensureIsLocalChannel,
41 videoChannelImportVideosValidator,
40 videoChannelsFollowersSortValidator, 42 videoChannelsFollowersSortValidator,
41 videoChannelsListValidator, 43 videoChannelsListValidator,
42 videoChannelsNameWithHostValidator, 44 videoChannelsNameWithHostValidator,
@@ -161,6 +163,16 @@ videoChannelRouter.get('/:nameWithHost/followers',
161 asyncMiddleware(listVideoChannelFollowers) 163 asyncMiddleware(listVideoChannelFollowers)
162) 164)
163 165
166videoChannelRouter.post('/:nameWithHost/import-videos',
167 authenticate,
168 asyncMiddleware(videoChannelsNameWithHostValidator),
169 videoChannelImportVideosValidator,
170 ensureIsLocalChannel,
171 ensureCanManageChannel,
172 asyncMiddleware(ensureChannelOwnerCanUpload),
173 asyncMiddleware(importVideosInChannel)
174)
175
164// --------------------------------------------------------------------------- 176// ---------------------------------------------------------------------------
165 177
166export { 178export {
@@ -404,3 +416,19 @@ async function listVideoChannelFollowers (req: express.Request, res: express.Res
404 416
405 return res.json(getFormattedObjects(resultList.data, resultList.total)) 417 return res.json(getFormattedObjects(resultList.data, resultList.total))
406} 418}
419
420async function importVideosInChannel (req: express.Request, res: express.Response) {
421 const { externalChannelUrl } = req.body
422
423 await JobQueue.Instance.createJob({
424 type: 'video-channel-import',
425 payload: {
426 externalChannelUrl,
427 videoChannelId: res.locals.videoChannel.id
428 }
429 })
430
431 logger.info('Video import job for channel "%s" with url "%s" created.', res.locals.videoChannel.name, externalChannelUrl)
432
433 return res.type('json').status(HttpStatusCode.NO_CONTENT_204).end()
434}