aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-11-15 15:06:03 +0100
committerChocobozzz <me@florianbigard.com>2019-11-25 10:59:43 +0100
commitd7a25329f9e607894d29ab342b9cb66638b56dc0 (patch)
tree6cd6bc4f2689f78944238b313c93427423a932ac /server/middlewares/validators
parent14981d7331da3f63fe6cfaf020ccb7c910006eaf (diff)
downloadPeerTube-d7a25329f9e607894d29ab342b9cb66638b56dc0.tar.gz
PeerTube-d7a25329f9e607894d29ab342b9cb66638b56dc0.tar.zst
PeerTube-d7a25329f9e607894d29ab342b9cb66638b56dc0.zip
Add ability to disable webtorrent
In favour of HLS
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r--server/middlewares/validators/config.ts17
-rw-r--r--server/middlewares/validators/videos/videos.ts2
2 files changed, 18 insertions, 1 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
87function 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}
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 = [
270 270
271 const user = res.locals.oauth.token.User 271 const user = res.locals.oauth.token.User
272 const videoChangeOwnership = res.locals.videoChangeOwnership 272 const videoChangeOwnership = res.locals.videoChangeOwnership
273 const isAble = await user.isAbleToUploadVideo(videoChangeOwnership.Video.getOriginalFile()) 273 const isAble = await user.isAbleToUploadVideo(videoChangeOwnership.Video.getMaxQualityFile())
274 if (isAble === false) { 274 if (isAble === false) {
275 res.status(403) 275 res.status(403)
276 .json({ error: 'The user video quota is exceeded with this video.' }) 276 .json({ error: 'The user video quota is exceeded with this video.' })