aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-02 16:33:29 +0200
committerChocobozzz <me@florianbigard.com>2018-08-06 11:19:16 +0200
commit299474e8279675adb6c5ce140e7e39c6f3439453 (patch)
tree32962c4a6878e4f4268e10eb0fbb9db670013ad3 /server/helpers/custom-validators
parentce32426be941164d041526e4748b4c83cdc6bf1c (diff)
downloadPeerTube-299474e8279675adb6c5ce140e7e39c6f3439453.tar.gz
PeerTube-299474e8279675adb6c5ce140e7e39c6f3439453.tar.zst
PeerTube-299474e8279675adb6c5ce140e7e39c6f3439453.zip
Add ability to remove a video import
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}