aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-07 10:07:53 +0200
committerChocobozzz <me@florianbigard.com>2018-08-08 09:30:31 +0200
commita84b8fa5cf6e4cafb841af3db9bdfcc9531c09a4 (patch)
treecf2feafcfadb5b6e9784c86d67e692db8d599b7d /server/middlewares
parent990b6a0b0c4fbebc165e5cf7cec8fbc1cbaa6c66 (diff)
downloadPeerTube-a84b8fa5cf6e4cafb841af3db9bdfcc9531c09a4.tar.gz
PeerTube-a84b8fa5cf6e4cafb841af3db9bdfcc9531c09a4.tar.zst
PeerTube-a84b8fa5cf6e4cafb841af3db9bdfcc9531c09a4.zip
Add import.video.torrent configuration
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/validators/config.ts1
-rw-r--r--server/middlewares/validators/video-imports.ts15
2 files changed, 12 insertions, 4 deletions
diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.ts
index 9d303eee2..f3f257d57 100644
--- a/server/middlewares/validators/config.ts
+++ b/server/middlewares/validators/config.ts
@@ -25,6 +25,7 @@ const customConfigUpdateValidator = [
25 body('transcoding.resolutions.720p').isBoolean().withMessage('Should have a valid transcoding 720p resolution enabled boolean'), 25 body('transcoding.resolutions.720p').isBoolean().withMessage('Should have a valid transcoding 720p resolution enabled boolean'),
26 body('transcoding.resolutions.1080p').isBoolean().withMessage('Should have a valid transcoding 1080p resolution enabled boolean'), 26 body('transcoding.resolutions.1080p').isBoolean().withMessage('Should have a valid transcoding 1080p resolution enabled boolean'),
27 body('import.videos.http.enabled').isBoolean().withMessage('Should have a valid import video http enabled boolean'), 27 body('import.videos.http.enabled').isBoolean().withMessage('Should have a valid import video http enabled boolean'),
28 body('import.videos.torrent.enabled').isBoolean().withMessage('Should have a valid import video torrent enabled boolean'),
28 29
29 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 30 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
30 logger.debug('Checking customConfigUpdateValidator parameters', { parameters: req.body }) 31 logger.debug('Checking customConfigUpdateValidator parameters', { parameters: req.body })
diff --git a/server/middlewares/validators/video-imports.ts b/server/middlewares/validators/video-imports.ts
index c03cf2e4d..9ac739101 100644
--- a/server/middlewares/validators/video-imports.ts
+++ b/server/middlewares/validators/video-imports.ts
@@ -33,21 +33,28 @@ const videoImportAddValidator = getCommonVideoAttributes().concat([
33 logger.debug('Checking videoImportAddValidator parameters', { parameters: req.body }) 33 logger.debug('Checking videoImportAddValidator parameters', { parameters: req.body })
34 34
35 const user = res.locals.oauth.token.User 35 const user = res.locals.oauth.token.User
36 const torrentFile = req.files && req.files['torrentfile'] ? req.files['torrentfile'][0] : undefined
36 37
37 if (areValidationErrors(req, res)) return cleanUpReqFiles(req) 38 if (areValidationErrors(req, res)) return cleanUpReqFiles(req)
38 39
39 if (CONFIG.IMPORT.VIDEOS.HTTP.ENABLED !== true) { 40 if (req.body.targetUrl && CONFIG.IMPORT.VIDEOS.HTTP.ENABLED !== true) {
40 cleanUpReqFiles(req) 41 cleanUpReqFiles(req)
41 return res.status(409) 42 return res.status(409)
42 .json({ error: 'Import is not enabled on this instance.' }) 43 .json({ error: 'HTTP import is not enabled on this instance.' })
43 .end() 44 .end()
44 } 45 }
45 46
47 if (CONFIG.IMPORT.VIDEOS.TORRENT.ENABLED !== true && (req.body.magnetUri || torrentFile)) {
48 cleanUpReqFiles(req)
49 return res.status(409)
50 .json({ error: 'Torrent/magnet URI import is not enabled on this instance.' })
51 .end()
52 }
53
46 if (!await isVideoChannelOfAccountExist(req.body.channelId, user, res)) return cleanUpReqFiles(req) 54 if (!await isVideoChannelOfAccountExist(req.body.channelId, user, res)) return cleanUpReqFiles(req)
47 55
48 // Check we have at least 1 required param 56 // Check we have at least 1 required param
49 const file = req.files['torrentfile'][0] 57 if (!req.body.targetUrl && !req.body.magnetUri && !torrentFile) {
50 if (!req.body.targetUrl && !req.body.magnetUri && !file) {
51 cleanUpReqFiles(req) 58 cleanUpReqFiles(req)
52 59
53 return res.status(400) 60 return res.status(400)