diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-02 16:33:29 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-06 11:19:16 +0200 |
commit | 299474e8279675adb6c5ce140e7e39c6f3439453 (patch) | |
tree | 32962c4a6878e4f4268e10eb0fbb9db670013ad3 /server/helpers | |
parent | ce32426be941164d041526e4748b4c83cdc6bf1c (diff) | |
download | PeerTube-299474e8279675adb6c5ce140e7e39c6f3439453.tar.gz PeerTube-299474e8279675adb6c5ce140e7e39c6f3439453.tar.zst PeerTube-299474e8279675adb6c5ce140e7e39c6f3439453.zip |
Add ability to remove a video import
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 | } |