aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/video-blacklist.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-10-05 11:15:06 +0200
committerChocobozzz <me@florianbigard.com>2018-10-05 11:22:38 +0200
commit6e46de095d7169355dd83030f6ce4a582304153a (patch)
treedfa78e2008d3d135a00b798b05350b4975145acc /server/middlewares/validators/video-blacklist.ts
parenta585824160d016db7c9bff0e1cb1ffa3aaf73d74 (diff)
downloadPeerTube-6e46de095d7169355dd83030f6ce4a582304153a.tar.gz
PeerTube-6e46de095d7169355dd83030f6ce4a582304153a.tar.zst
PeerTube-6e46de095d7169355dd83030f6ce4a582304153a.zip
Add user history and resume videos
Diffstat (limited to 'server/middlewares/validators/video-blacklist.ts')
-rw-r--r--server/middlewares/validators/video-blacklist.ts62
1 files changed, 0 insertions, 62 deletions
diff --git a/server/middlewares/validators/video-blacklist.ts b/server/middlewares/validators/video-blacklist.ts
deleted file mode 100644
index 95a2b9f17..000000000
--- a/server/middlewares/validators/video-blacklist.ts
+++ /dev/null
@@ -1,62 +0,0 @@
1import * as express from 'express'
2import { body, param } from 'express-validator/check'
3import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
4import { isVideoExist } from '../../helpers/custom-validators/videos'
5import { logger } from '../../helpers/logger'
6import { areValidationErrors } from './utils'
7import { isVideoBlacklistExist, isVideoBlacklistReasonValid } from '../../helpers/custom-validators/video-blacklist'
8
9const videosBlacklistRemoveValidator = [
10 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
11
12 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
13 logger.debug('Checking blacklistRemove parameters.', { parameters: req.params })
14
15 if (areValidationErrors(req, res)) return
16 if (!await isVideoExist(req.params.videoId, res)) return
17 if (!await isVideoBlacklistExist(res.locals.video.id, res)) return
18
19 return next()
20 }
21]
22
23const videosBlacklistAddValidator = [
24 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
25 body('reason')
26 .optional()
27 .custom(isVideoBlacklistReasonValid).withMessage('Should have a valid reason'),
28
29 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
30 logger.debug('Checking videosBlacklistAdd parameters', { parameters: req.params })
31
32 if (areValidationErrors(req, res)) return
33 if (!await isVideoExist(req.params.videoId, res)) return
34
35 return next()
36 }
37]
38
39const videosBlacklistUpdateValidator = [
40 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
41 body('reason')
42 .optional()
43 .custom(isVideoBlacklistReasonValid).withMessage('Should have a valid reason'),
44
45 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
46 logger.debug('Checking videosBlacklistUpdate parameters', { parameters: req.params })
47
48 if (areValidationErrors(req, res)) return
49 if (!await isVideoExist(req.params.videoId, res)) return
50 if (!await isVideoBlacklistExist(res.locals.video.id, res)) return
51
52 return next()
53 }
54]
55
56// ---------------------------------------------------------------------------
57
58export {
59 videosBlacklistAddValidator,
60 videosBlacklistRemoveValidator,
61 videosBlacklistUpdateValidator
62}