From d7a25329f9e607894d29ab342b9cb66638b56dc0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 15 Nov 2019 15:06:03 +0100 Subject: Add ability to disable webtorrent In favour of HLS --- server/middlewares/validators/config.ts | 17 +++++++++++++++++ server/middlewares/validators/videos/videos.ts | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'server/middlewares') diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.ts index 5059ed0f2..1db907f91 100644 --- a/server/middlewares/validators/config.ts +++ b/server/middlewares/validators/config.ts @@ -43,6 +43,9 @@ const customConfigUpdateValidator = [ body('transcoding.resolutions.720p').isBoolean().withMessage('Should have a valid transcoding 720p resolution enabled boolean'), body('transcoding.resolutions.1080p').isBoolean().withMessage('Should have a valid transcoding 1080p resolution enabled boolean'), + body('transcoding.webtorrent.enabled').isBoolean().withMessage('Should have a valid webtorrent transcoding enabled boolean'), + body('transcoding.hls.enabled').isBoolean().withMessage('Should have a valid webtorrent transcoding enabled boolean'), + body('import.videos.http.enabled').isBoolean().withMessage('Should have a valid import video http enabled boolean'), body('import.videos.torrent.enabled').isBoolean().withMessage('Should have a valid import video torrent enabled boolean'), @@ -56,6 +59,7 @@ const customConfigUpdateValidator = [ if (areValidationErrors(req, res)) return if (!checkInvalidConfigIfEmailDisabled(req.body as CustomConfig, res)) return + if (!checkInvalidTranscodingConfig(req.body as CustomConfig, res)) return return next() } @@ -79,3 +83,16 @@ function checkInvalidConfigIfEmailDisabled (customConfig: CustomConfig, res: exp return true } + +function checkInvalidTranscodingConfig (customConfig: CustomConfig, res: express.Response) { + if (customConfig.transcoding.enabled === false) return true + + if (customConfig.transcoding.webtorrent.enabled === false && customConfig.transcoding.hls.enabled === false) { + res.status(400) + .send({ error: 'You need to enable at least webtorrent transcoding or hls transcoding' }) + .end() + return false + } + + return true +} diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts index 1449903b7..53a2f193d 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts @@ -270,7 +270,7 @@ const videosAcceptChangeOwnershipValidator = [ const user = res.locals.oauth.token.User const videoChangeOwnership = res.locals.videoChangeOwnership - const isAble = await user.isAbleToUploadVideo(videoChangeOwnership.Video.getOriginalFile()) + const isAble = await user.isAbleToUploadVideo(videoChangeOwnership.Video.getMaxQualityFile()) if (isAble === false) { res.status(403) .json({ error: 'The user video quota is exceeded with this video.' }) -- cgit v1.2.3