diff options
Diffstat (limited to 'server/middlewares/validators/config.ts')
-rw-r--r-- | server/middlewares/validators/config.ts | 17 |
1 files changed, 17 insertions, 0 deletions
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 = [ | |||
43 | body('transcoding.resolutions.720p').isBoolean().withMessage('Should have a valid transcoding 720p resolution enabled boolean'), | 43 | body('transcoding.resolutions.720p').isBoolean().withMessage('Should have a valid transcoding 720p resolution enabled boolean'), |
44 | body('transcoding.resolutions.1080p').isBoolean().withMessage('Should have a valid transcoding 1080p resolution enabled boolean'), | 44 | body('transcoding.resolutions.1080p').isBoolean().withMessage('Should have a valid transcoding 1080p resolution enabled boolean'), |
45 | 45 | ||
46 | body('transcoding.webtorrent.enabled').isBoolean().withMessage('Should have a valid webtorrent transcoding enabled boolean'), | ||
47 | body('transcoding.hls.enabled').isBoolean().withMessage('Should have a valid webtorrent transcoding enabled boolean'), | ||
48 | |||
46 | body('import.videos.http.enabled').isBoolean().withMessage('Should have a valid import video http enabled boolean'), | 49 | body('import.videos.http.enabled').isBoolean().withMessage('Should have a valid import video http enabled boolean'), |
47 | body('import.videos.torrent.enabled').isBoolean().withMessage('Should have a valid import video torrent enabled boolean'), | 50 | body('import.videos.torrent.enabled').isBoolean().withMessage('Should have a valid import video torrent enabled boolean'), |
48 | 51 | ||
@@ -56,6 +59,7 @@ const customConfigUpdateValidator = [ | |||
56 | 59 | ||
57 | if (areValidationErrors(req, res)) return | 60 | if (areValidationErrors(req, res)) return |
58 | if (!checkInvalidConfigIfEmailDisabled(req.body as CustomConfig, res)) return | 61 | if (!checkInvalidConfigIfEmailDisabled(req.body as CustomConfig, res)) return |
62 | if (!checkInvalidTranscodingConfig(req.body as CustomConfig, res)) return | ||
59 | 63 | ||
60 | return next() | 64 | return next() |
61 | } | 65 | } |
@@ -79,3 +83,16 @@ function checkInvalidConfigIfEmailDisabled (customConfig: CustomConfig, res: exp | |||
79 | 83 | ||
80 | return true | 84 | return true |
81 | } | 85 | } |
86 | |||
87 | function checkInvalidTranscodingConfig (customConfig: CustomConfig, res: express.Response) { | ||
88 | if (customConfig.transcoding.enabled === false) return true | ||
89 | |||
90 | if (customConfig.transcoding.webtorrent.enabled === false && customConfig.transcoding.hls.enabled === false) { | ||
91 | res.status(400) | ||
92 | .send({ error: 'You need to enable at least webtorrent transcoding or hls transcoding' }) | ||
93 | .end() | ||
94 | return false | ||
95 | } | ||
96 | |||
97 | return true | ||
98 | } | ||