diff options
Diffstat (limited to 'server/middlewares/validators/videos/video-imports.ts')
-rw-r--r-- | server/middlewares/validators/videos/video-imports.ts | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/server/middlewares/validators/videos/video-imports.ts b/server/middlewares/validators/videos/video-imports.ts index d69aff118..0d41933a6 100644 --- a/server/middlewares/validators/videos/video-imports.ts +++ b/server/middlewares/validators/videos/video-imports.ts | |||
@@ -13,6 +13,7 @@ import { CONFIG } from '../../../initializers/config' | |||
13 | import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' | 13 | import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' |
14 | import { areValidationErrors } from '../utils' | 14 | import { areValidationErrors } from '../utils' |
15 | import { getCommonVideoEditAttributes } from './videos' | 15 | import { getCommonVideoEditAttributes } from './videos' |
16 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | ||
16 | 17 | ||
17 | const videoImportAddValidator = getCommonVideoEditAttributes().concat([ | 18 | const videoImportAddValidator = getCommonVideoEditAttributes().concat([ |
18 | body('channelId') | 19 | body('channelId') |
@@ -44,14 +45,14 @@ const videoImportAddValidator = getCommonVideoEditAttributes().concat([ | |||
44 | 45 | ||
45 | if (req.body.targetUrl && CONFIG.IMPORT.VIDEOS.HTTP.ENABLED !== true) { | 46 | if (req.body.targetUrl && CONFIG.IMPORT.VIDEOS.HTTP.ENABLED !== true) { |
46 | cleanUpReqFiles(req) | 47 | cleanUpReqFiles(req) |
47 | return res.status(409) | 48 | return res.status(HttpStatusCode.CONFLICT_409) |
48 | .json({ error: 'HTTP import is not enabled on this instance.' }) | 49 | .json({ error: 'HTTP import is not enabled on this instance.' }) |
49 | .end() | 50 | .end() |
50 | } | 51 | } |
51 | 52 | ||
52 | if (CONFIG.IMPORT.VIDEOS.TORRENT.ENABLED !== true && (req.body.magnetUri || torrentFile)) { | 53 | if (CONFIG.IMPORT.VIDEOS.TORRENT.ENABLED !== true && (req.body.magnetUri || torrentFile)) { |
53 | cleanUpReqFiles(req) | 54 | cleanUpReqFiles(req) |
54 | return res.status(409) | 55 | return res.status(HttpStatusCode.CONFLICT_409) |
55 | .json({ error: 'Torrent/magnet URI import is not enabled on this instance.' }) | 56 | .json({ error: 'Torrent/magnet URI import is not enabled on this instance.' }) |
56 | .end() | 57 | .end() |
57 | } | 58 | } |
@@ -62,7 +63,7 @@ const videoImportAddValidator = getCommonVideoEditAttributes().concat([ | |||
62 | if (!req.body.targetUrl && !req.body.magnetUri && !torrentFile) { | 63 | if (!req.body.targetUrl && !req.body.magnetUri && !torrentFile) { |
63 | cleanUpReqFiles(req) | 64 | cleanUpReqFiles(req) |
64 | 65 | ||
65 | return res.status(400) | 66 | return res.status(HttpStatusCode.BAD_REQUEST_400) |
66 | .json({ error: 'Should have a magnetUri or a targetUrl or a torrent file.' }) | 67 | .json({ error: 'Should have a magnetUri or a targetUrl or a torrent file.' }) |
67 | .end() | 68 | .end() |
68 | } | 69 | } |
@@ -100,7 +101,7 @@ async function isImportAccepted (req: express.Request, res: express.Response) { | |||
100 | 101 | ||
101 | if (!acceptedResult || acceptedResult.accepted !== true) { | 102 | if (!acceptedResult || acceptedResult.accepted !== true) { |
102 | logger.info('Refused to import video.', { acceptedResult, acceptParameters }) | 103 | logger.info('Refused to import video.', { acceptedResult, acceptParameters }) |
103 | res.status(403) | 104 | res.status(HttpStatusCode.FORBIDDEN_403) |
104 | .json({ error: acceptedResult.errorMessage || 'Refused to import video' }) | 105 | .json({ error: acceptedResult.errorMessage || 'Refused to import video' }) |
105 | 106 | ||
106 | return false | 107 | return false |