aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/video-imports.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators/video-imports.ts')
-rw-r--r--server/middlewares/validators/video-imports.ts15
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)