diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-03 09:43:00 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-06 11:19:16 +0200 |
commit | 516df59b3bbb0218afeda595ee4966800bff4519 (patch) | |
tree | 4687691eeb0bf9c2846b673253c54628409345d1 /server/middlewares | |
parent | d7f83948a1af0ef3bed61f83e87e826902c96f7d (diff) | |
download | PeerTube-516df59b3bbb0218afeda595ee4966800bff4519.tar.gz PeerTube-516df59b3bbb0218afeda595ee4966800bff4519.tar.zst PeerTube-516df59b3bbb0218afeda595ee4966800bff4519.zip |
Remove ability to delete video imports
Users should remove the linked video instead
Diffstat (limited to 'server/middlewares')
-rw-r--r-- | server/middlewares/validators/video-imports.ts | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/server/middlewares/validators/video-imports.ts b/server/middlewares/validators/video-imports.ts index 0dedcf803..e0a552976 100644 --- a/server/middlewares/validators/video-imports.ts +++ b/server/middlewares/validators/video-imports.ts | |||
@@ -1,14 +1,12 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { body, param } from 'express-validator/check' | 2 | import { body } from 'express-validator/check' |
3 | import { isIdValid } from '../../helpers/custom-validators/misc' | 3 | import { isIdValid } from '../../helpers/custom-validators/misc' |
4 | import { logger } from '../../helpers/logger' | 4 | import { logger } from '../../helpers/logger' |
5 | import { areValidationErrors } from './utils' | 5 | import { areValidationErrors } from './utils' |
6 | import { getCommonVideoAttributes } from './videos' | 6 | import { getCommonVideoAttributes } from './videos' |
7 | import { isVideoImportTargetUrlValid, isVideoImportExist } from '../../helpers/custom-validators/video-imports' | 7 | import { isVideoImportTargetUrlValid } from '../../helpers/custom-validators/video-imports' |
8 | import { cleanUpReqFiles } from '../../helpers/utils' | 8 | import { cleanUpReqFiles } from '../../helpers/utils' |
9 | import { isVideoChannelOfAccountExist, isVideoNameValid, checkUserCanManageVideo } from '../../helpers/custom-validators/videos' | 9 | import { isVideoChannelOfAccountExist, isVideoNameValid } from '../../helpers/custom-validators/videos' |
10 | import { VideoImportModel } from '../../models/video/video-import' | ||
11 | import { UserRight } from '../../../shared' | ||
12 | 10 | ||
13 | const videoImportAddValidator = getCommonVideoAttributes().concat([ | 11 | const videoImportAddValidator = getCommonVideoAttributes().concat([ |
14 | body('targetUrl').custom(isVideoImportTargetUrlValid).withMessage('Should have a valid video import target URL'), | 12 | body('targetUrl').custom(isVideoImportTargetUrlValid).withMessage('Should have a valid video import target URL'), |
@@ -31,29 +29,10 @@ const videoImportAddValidator = getCommonVideoAttributes().concat([ | |||
31 | } | 29 | } |
32 | ]) | 30 | ]) |
33 | 31 | ||
34 | const videoImportDeleteValidator = [ | ||
35 | param('id').custom(isIdValid).not().isEmpty().withMessage('Should have a valid id'), | ||
36 | |||
37 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
38 | logger.debug('Checking videoImportDeleteValidator parameters', { parameters: req.body }) | ||
39 | |||
40 | if (areValidationErrors(req, res)) return | ||
41 | if (!await isVideoImportExist(req.params.id, res)) return | ||
42 | |||
43 | const user = res.locals.oauth.token.User | ||
44 | const videoImport: VideoImportModel = res.locals.videoImport | ||
45 | |||
46 | if (!await checkUserCanManageVideo(user, videoImport.Video, UserRight.UPDATE_ANY_VIDEO, res)) return | ||
47 | |||
48 | return next() | ||
49 | } | ||
50 | ] | ||
51 | |||
52 | // --------------------------------------------------------------------------- | 32 | // --------------------------------------------------------------------------- |
53 | 33 | ||
54 | export { | 34 | export { |
55 | videoImportAddValidator, | 35 | videoImportAddValidator |
56 | videoImportDeleteValidator | ||
57 | } | 36 | } |
58 | 37 | ||
59 | // --------------------------------------------------------------------------- | 38 | // --------------------------------------------------------------------------- |