diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-10-26 10:40:37 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-10-26 10:40:37 +0200 |
commit | 51c443dbe0284c5ec54033be06f554ec37397bce (patch) | |
tree | 5312f85f1c8b9c62a77c05c8e440e301e5be3137 /server/middlewares/validators/remote | |
parent | faab3a8453e2af92f95518e55e00293ac140b6e8 (diff) | |
download | PeerTube-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/remote')
-rw-r--r-- | server/middlewares/validators/remote/videos.ts | 31 |
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 | ||
4 | import { | 4 | import { |
5 | logger, | 5 | logger, |
6 | isEachRemoteRequestVideosValid, | 6 | isArray, |
7 | isEachRemoteRequestVideosQaduValid, | 7 | removeBadRequestVideos, |
8 | isEachRemoteRequestVideosEventsValid | 8 | removeBadRequestVideosQadu, |
9 | removeBadRequestVideosEvents | ||
9 | } from '../../../helpers' | 10 | } from '../../../helpers' |
10 | import { checkErrors } from '../utils' | 11 | import { checkErrors } from '../utils' |
11 | 12 | ||
12 | const remoteVideosValidator = [ | 13 | const 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 | ||
22 | const remoteQaduVideosValidator = [ | 27 | const 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 | ||
32 | const remoteEventsVideosValidator = [ | 41 | const 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 | ||