aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-10-26 10:40:37 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-10-26 10:40:37 +0200
commit51c443dbe0284c5ec54033be06f554ec37397bce (patch)
tree5312f85f1c8b9c62a77c05c8e440e301e5be3137 /server/middlewares/validators
parentfaab3a8453e2af92f95518e55e00293ac140b6e8 (diff)
downloadPeerTube-51c443dbe0284c5ec54033be06f554ec37397bce.tar.gz
PeerTube-51c443dbe0284c5ec54033be06f554ec37397bce.tar.zst
PeerTube-51c443dbe0284c5ec54033be06f554ec37397bce.zip
Be tolerant with remote requests
Just remove videos we don't want
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r--server/middlewares/validators/remote/videos.ts31
1 files changed, 22 insertions, 9 deletions
diff --git a/server/middlewares/validators/remote/videos.ts b/server/middlewares/validators/remote/videos.ts
index e4682a60b..497320cc1 100644
--- a/server/middlewares/validators/remote/videos.ts
+++ b/server/middlewares/validators/remote/videos.ts
@@ -3,39 +3,52 @@ import * as express from 'express'
3 3
4import { 4import {
5 logger, 5 logger,
6 isEachRemoteRequestVideosValid, 6 isArray,
7 isEachRemoteRequestVideosQaduValid, 7 removeBadRequestVideos,
8 isEachRemoteRequestVideosEventsValid 8 removeBadRequestVideosQadu,
9 removeBadRequestVideosEvents
9} from '../../../helpers' 10} from '../../../helpers'
10import { checkErrors } from '../utils' 11import { checkErrors } from '../utils'
11 12
12const remoteVideosValidator = [ 13const remoteVideosValidator = [
13 body('data').custom(isEachRemoteRequestVideosValid), 14 body('data').custom(isArray),
14 15
15 (req: express.Request, res: express.Response, next: express.NextFunction) => { 16 (req: express.Request, res: express.Response, next: express.NextFunction) => {
16 logger.debug('Checking remoteVideos parameters', { parameters: req.body }) 17 logger.debug('Checking remoteVideos parameters', { parameters: req.body })
17 18
18 checkErrors(req, res, next) 19 checkErrors(req, res, () => {
20 removeBadRequestVideos(req.body.data)
21
22 return next()
23 })
19 } 24 }
20] 25]
21 26
22const remoteQaduVideosValidator = [ 27const remoteQaduVideosValidator = [
23 body('data').custom(isEachRemoteRequestVideosQaduValid), 28 body('data').custom(isArray),
24 29
25 (req: express.Request, res: express.Response, next: express.NextFunction) => { 30 (req: express.Request, res: express.Response, next: express.NextFunction) => {
26 logger.debug('Checking remoteQaduVideos parameters', { parameters: req.body }) 31 logger.debug('Checking remoteQaduVideos parameters', { parameters: req.body })
27 32
28 checkErrors(req, res, next) 33 checkErrors(req, res, () => {
34 removeBadRequestVideosQadu(req.body.data)
35
36 return next()
37 })
29 } 38 }
30] 39]
31 40
32const remoteEventsVideosValidator = [ 41const remoteEventsVideosValidator = [
33 body('data').custom(isEachRemoteRequestVideosEventsValid), 42 body('data').custom(isArray),
34 43
35 (req: express.Request, res: express.Response, next: express.NextFunction) => { 44 (req: express.Request, res: express.Response, next: express.NextFunction) => {
36 logger.debug('Checking remoteEventsVideos parameters', { parameters: req.body }) 45 logger.debug('Checking remoteEventsVideos parameters', { parameters: req.body })
37 46
38 checkErrors(req, res, next) 47 checkErrors(req, res, () => {
48 removeBadRequestVideosEvents(req.body.data)
49
50 return next()
51 })
39 } 52 }
40] 53]
41 54