-export {
- videoChannelsAddValidator,
- videoChannelsUpdateValidator,
- videoChannelsRemoveValidator,
- videoChannelsNameWithHostValidator,
- ensureIsLocalChannel,
- videoChannelsListValidator,
- videoChannelStatsValidator
-}
+ body('videoChannelSyncId')
+ .optional()
+ .custom(isIdValid),
+
+ async (req: express.Request, res: express.Response, next: express.NextFunction) => {
+ if (areValidationErrors(req, res)) return
+
+ const body: VideosImportInChannelCreate = req.body
+
+ if (!CONFIG.IMPORT.VIDEOS.HTTP.ENABLED) {
+ return res.fail({
+ status: HttpStatusCode.FORBIDDEN_403,
+ message: 'Channel import is impossible as video upload via HTTP is not enabled on the server'
+ })
+ }
+
+ if (body.videoChannelSyncId && !await doesVideoChannelSyncIdExist(body.videoChannelSyncId, res)) return
+
+ if (res.locals.videoChannelSync && res.locals.videoChannelSync.videoChannelId !== res.locals.videoChannel.id) {
+ return res.fail({
+ status: HttpStatusCode.FORBIDDEN_403,
+ message: 'This channel sync is not owned by this channel'
+ })
+ }
+
+ return next()
+ }
+]