aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-10 14:34:45 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:51 +0100
commit0d0e8dd0904b380b70e19ebcb4763d65601c4632 (patch)
treeacb625d7c88fbe863fa14bf6783fafe4a8e35137 /server/middlewares
parente4f97babf701481b55cc10fb3448feab5f97c867 (diff)
downloadPeerTube-0d0e8dd0904b380b70e19ebcb4763d65601c4632.tar.gz
PeerTube-0d0e8dd0904b380b70e19ebcb4763d65601c4632.tar.zst
PeerTube-0d0e8dd0904b380b70e19ebcb4763d65601c4632.zip
Continue activitypub
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}