aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r--server/helpers/custom-validators/video-imports.ts21
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'
3import * as validator from 'validator' 3import * as validator from 'validator'
4import { CONSTRAINTS_FIELDS, VIDEO_IMPORT_STATES } from '../../initializers' 4import { CONSTRAINTS_FIELDS, VIDEO_IMPORT_STATES } from '../../initializers'
5import { exists } from './misc' 5import { exists } from './misc'
6import * as express from 'express'
7import { VideoChannelModel } from '../../models/video/video-channel'
8import { VideoImportModel } from '../../models/video/video-import'
6 9
7function isVideoImportTargetUrlValid (url: string) { 10function 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
28async 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
27export { 45export {
28 isVideoImportStateValid, 46 isVideoImportStateValid,
29 isVideoImportTargetUrlValid 47 isVideoImportTargetUrlValid,
48 isVideoImportExist
30} 49}