diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-03 11:10:31 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-06 11:19:16 +0200 |
commit | 5d08a6a74e83f2e4dfe2f3ba7f5a39371e1bc89e (patch) | |
tree | dd992ea798c620b8bdb5bf5fd9b8f1b97d4410f2 /server/middlewares/validators/video-imports.ts | |
parent | 7e5f9f001d5de22c54748f935edc0c069028bb0e (diff) | |
download | PeerTube-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.ts | 9 |
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' | |||
7 | import { isVideoImportTargetUrlValid } from '../../helpers/custom-validators/video-imports' | 7 | import { isVideoImportTargetUrlValid } from '../../helpers/custom-validators/video-imports' |
8 | import { cleanUpReqFiles } from '../../helpers/utils' | 8 | import { cleanUpReqFiles } from '../../helpers/utils' |
9 | import { isVideoChannelOfAccountExist, isVideoNameValid } from '../../helpers/custom-validators/videos' | 9 | import { isVideoChannelOfAccountExist, isVideoNameValid } from '../../helpers/custom-validators/videos' |
10 | import { CONFIG } from '../../initializers/constants' | ||
10 | 11 | ||
11 | const videoImportAddValidator = getCommonVideoAttributes().concat([ | 12 | const 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() |