aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/video-imports.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-03 11:10:31 +0200
committerChocobozzz <me@florianbigard.com>2018-08-06 11:19:16 +0200
commit5d08a6a74e83f2e4dfe2f3ba7f5a39371e1bc89e (patch)
treedd992ea798c620b8bdb5bf5fd9b8f1b97d4410f2 /server/middlewares/validators/video-imports.ts
parent7e5f9f001d5de22c54748f935edc0c069028bb0e (diff)
downloadPeerTube-5d08a6a74e83f2e4dfe2f3ba7f5a39371e1bc89e.tar.gz
PeerTube-5d08a6a74e83f2e4dfe2f3ba7f5a39371e1bc89e.tar.zst
PeerTube-5d08a6a74e83f2e4dfe2f3ba7f5a39371e1bc89e.zip
Add import http enabled configuration
Diffstat (limited to 'server/middlewares/validators/video-imports.ts')
-rw-r--r--server/middlewares/validators/video-imports.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/server/middlewares/validators/video-imports.ts b/server/middlewares/validators/video-imports.ts
index e0a552976..d806edfa3 100644
--- a/server/middlewares/validators/video-imports.ts
+++ b/server/middlewares/validators/video-imports.ts
@@ -7,6 +7,7 @@ import { getCommonVideoAttributes } from './videos'
7import { isVideoImportTargetUrlValid } from '../../helpers/custom-validators/video-imports' 7import { isVideoImportTargetUrlValid } from '../../helpers/custom-validators/video-imports'
8import { cleanUpReqFiles } from '../../helpers/utils' 8import { cleanUpReqFiles } from '../../helpers/utils'
9import { isVideoChannelOfAccountExist, isVideoNameValid } from '../../helpers/custom-validators/videos' 9import { isVideoChannelOfAccountExist, isVideoNameValid } from '../../helpers/custom-validators/videos'
10import { CONFIG } from '../../initializers/constants'
10 11
11const videoImportAddValidator = getCommonVideoAttributes().concat([ 12const videoImportAddValidator = getCommonVideoAttributes().concat([
12 body('targetUrl').custom(isVideoImportTargetUrlValid).withMessage('Should have a valid video import target URL'), 13 body('targetUrl').custom(isVideoImportTargetUrlValid).withMessage('Should have a valid video import target URL'),
@@ -23,6 +24,14 @@ const videoImportAddValidator = getCommonVideoAttributes().concat([
23 const user = res.locals.oauth.token.User 24 const user = res.locals.oauth.token.User
24 25
25 if (areValidationErrors(req, res)) return cleanUpReqFiles(req) 26 if (areValidationErrors(req, res)) return cleanUpReqFiles(req)
27
28 if (CONFIG.IMPORT.VIDEOS.HTTP.ENABLED !== true) {
29 cleanUpReqFiles(req)
30 return res.status(409)
31 .json({ error: 'Import is not enabled on this instance.' })
32 .end()
33 }
34
26 if (!await isVideoChannelOfAccountExist(req.body.channelId, user, res)) return cleanUpReqFiles(req) 35 if (!await isVideoChannelOfAccountExist(req.body.channelId, user, res)) return cleanUpReqFiles(req)
27 36
28 return next() 37 return next()