aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/validators/activitypub/activity.ts21
-rw-r--r--server/middlewares/validators/activitypub/videos.ts61
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 @@
1import { body } from 'express-validator/check'
2import * as express from 'express'
3
4import { logger, isRootActivityValid } from '../../../helpers'
5import { checkErrors } from '../utils'
6
7const 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
19export {
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 @@
1import { body } from 'express-validator/check'
2import * as express from 'express'
3
4import {
5 logger,
6 isArray,
7 removeBadRequestVideos,
8 removeBadRequestVideosQadu,
9 removeBadRequestVideosEvents
10} from '../../../helpers'
11import { checkErrors } from '../utils'
12
13const 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
27const 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
41const 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
57export {
58 remoteVideosValidator,
59 remoteQaduVideosValidator,
60 remoteEventsVideosValidator
61}