diff options
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/custom-validators/video-imports.ts | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/server/helpers/custom-validators/video-imports.ts b/server/helpers/custom-validators/video-imports.ts index 36c0559fd..d8b9bfaff 100644 --- a/server/helpers/custom-validators/video-imports.ts +++ b/server/helpers/custom-validators/video-imports.ts | |||
@@ -3,6 +3,9 @@ import 'multer' | |||
3 | import * as validator from 'validator' | 3 | import * as validator from 'validator' |
4 | import { CONSTRAINTS_FIELDS, VIDEO_IMPORT_STATES } from '../../initializers' | 4 | import { CONSTRAINTS_FIELDS, VIDEO_IMPORT_STATES } from '../../initializers' |
5 | import { exists } from './misc' | 5 | import { exists } from './misc' |
6 | import * as express from 'express' | ||
7 | import { VideoChannelModel } from '../../models/video/video-channel' | ||
8 | import { VideoImportModel } from '../../models/video/video-import' | ||
6 | 9 | ||
7 | function isVideoImportTargetUrlValid (url: string) { | 10 | function isVideoImportTargetUrlValid (url: string) { |
8 | const isURLOptions = { | 11 | const isURLOptions = { |
@@ -22,9 +25,25 @@ function isVideoImportStateValid (value: any) { | |||
22 | return exists(value) && VIDEO_IMPORT_STATES[ value ] !== undefined | 25 | return exists(value) && VIDEO_IMPORT_STATES[ value ] !== undefined |
23 | } | 26 | } |
24 | 27 | ||
28 | async function isVideoImportExist (id: number, res: express.Response) { | ||
29 | const videoImport = await VideoImportModel.loadAndPopulateVideo(id) | ||
30 | |||
31 | if (!videoImport) { | ||
32 | res.status(404) | ||
33 | .json({ error: 'Video import not found' }) | ||
34 | .end() | ||
35 | |||
36 | return false | ||
37 | } | ||
38 | |||
39 | res.locals.videoImport = videoImport | ||
40 | return true | ||
41 | } | ||
42 | |||
25 | // --------------------------------------------------------------------------- | 43 | // --------------------------------------------------------------------------- |
26 | 44 | ||
27 | export { | 45 | export { |
28 | isVideoImportStateValid, | 46 | isVideoImportStateValid, |
29 | isVideoImportTargetUrlValid | 47 | isVideoImportTargetUrlValid, |
48 | isVideoImportExist | ||
30 | } | 49 | } |