diff options
Diffstat (limited to 'server/middlewares')
-rw-r--r-- | server/middlewares/validators/activitypub/activity.ts | 21 | ||||
-rw-r--r-- | server/middlewares/validators/activitypub/videos.ts | 61 |
2 files changed, 21 insertions, 61 deletions
diff --git a/server/middlewares/validators/activitypub/activity.ts b/server/middlewares/validators/activitypub/activity.ts new file mode 100644 index 000000000..78a6d1444 --- /dev/null +++ b/server/middlewares/validators/activitypub/activity.ts | |||
@@ -0,0 +1,21 @@ | |||
1 | import { body } from 'express-validator/check' | ||
2 | import * as express from 'express' | ||
3 | |||
4 | import { logger, isRootActivityValid } from '../../../helpers' | ||
5 | import { checkErrors } from '../utils' | ||
6 | |||
7 | const activityPubValidator = [ | ||
8 | body('data').custom(isRootActivityValid), | ||
9 | |||
10 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
11 | logger.debug('Checking activity pub parameters', { parameters: req.body }) | ||
12 | |||
13 | checkErrors(req, res, next) | ||
14 | } | ||
15 | ] | ||
16 | |||
17 | // --------------------------------------------------------------------------- | ||
18 | |||
19 | export { | ||
20 | activityPubValidator | ||
21 | } | ||
diff --git a/server/middlewares/validators/activitypub/videos.ts b/server/middlewares/validators/activitypub/videos.ts deleted file mode 100644 index 497320cc1..000000000 --- a/server/middlewares/validators/activitypub/videos.ts +++ /dev/null | |||
@@ -1,61 +0,0 @@ | |||
1 | import { body } from 'express-validator/check' | ||
2 | import * as express from 'express' | ||
3 | |||
4 | import { | ||
5 | logger, | ||
6 | isArray, | ||
7 | removeBadRequestVideos, | ||
8 | removeBadRequestVideosQadu, | ||
9 | removeBadRequestVideosEvents | ||
10 | } from '../../../helpers' | ||
11 | import { checkErrors } from '../utils' | ||
12 | |||
13 | const remoteVideosValidator = [ | ||
14 | body('data').custom(isArray), | ||
15 | |||
16 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
17 | logger.debug('Checking remoteVideos parameters', { parameters: req.body }) | ||
18 | |||
19 | checkErrors(req, res, () => { | ||
20 | removeBadRequestVideos(req.body.data) | ||
21 | |||
22 | return next() | ||
23 | }) | ||
24 | } | ||
25 | ] | ||
26 | |||
27 | const remoteQaduVideosValidator = [ | ||
28 | body('data').custom(isArray), | ||
29 | |||
30 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
31 | logger.debug('Checking remoteQaduVideos parameters', { parameters: req.body }) | ||
32 | |||
33 | checkErrors(req, res, () => { | ||
34 | removeBadRequestVideosQadu(req.body.data) | ||
35 | |||
36 | return next() | ||
37 | }) | ||
38 | } | ||
39 | ] | ||
40 | |||
41 | const remoteEventsVideosValidator = [ | ||
42 | body('data').custom(isArray), | ||
43 | |||
44 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
45 | logger.debug('Checking remoteEventsVideos parameters', { parameters: req.body }) | ||
46 | |||
47 | checkErrors(req, res, () => { | ||
48 | removeBadRequestVideosEvents(req.body.data) | ||
49 | |||
50 | return next() | ||
51 | }) | ||
52 | } | ||
53 | ] | ||
54 | |||
55 | // --------------------------------------------------------------------------- | ||
56 | |||
57 | export { | ||
58 | remoteVideosValidator, | ||
59 | remoteQaduVideosValidator, | ||
60 | remoteEventsVideosValidator | ||
61 | } | ||