diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-07 10:07:53 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-08 09:30:31 +0200 |
commit | a84b8fa5cf6e4cafb841af3db9bdfcc9531c09a4 (patch) | |
tree | cf2feafcfadb5b6e9784c86d67e692db8d599b7d /server/middlewares/validators/video-imports.ts | |
parent | 990b6a0b0c4fbebc165e5cf7cec8fbc1cbaa6c66 (diff) | |
download | PeerTube-a84b8fa5cf6e4cafb841af3db9bdfcc9531c09a4.tar.gz PeerTube-a84b8fa5cf6e4cafb841af3db9bdfcc9531c09a4.tar.zst PeerTube-a84b8fa5cf6e4cafb841af3db9bdfcc9531c09a4.zip |
Add import.video.torrent configuration
Diffstat (limited to 'server/middlewares/validators/video-imports.ts')
-rw-r--r-- | server/middlewares/validators/video-imports.ts | 15 |
1 files changed, 11 insertions, 4 deletions
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) |