aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/remote
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-09 17:51:58 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:51 +0100
commite4f97babf701481b55cc10fb3448feab5f97c867 (patch)
treeaf37402a594dc5ff09f71ecb0687e8cfe4cdb471 /server/middlewares/validators/remote
parent343ad675f2a26c15b86150a9a3552e619d5d44f4 (diff)
downloadPeerTube-e4f97babf701481b55cc10fb3448feab5f97c867.tar.gz
PeerTube-e4f97babf701481b55cc10fb3448feab5f97c867.tar.zst
PeerTube-e4f97babf701481b55cc10fb3448feab5f97c867.zip
Begin activitypub
Diffstat (limited to 'server/middlewares/validators/remote')
-rw-r--r--server/middlewares/validators/remote/index.ts3
-rw-r--r--server/middlewares/validators/remote/pods.ts38
-rw-r--r--server/middlewares/validators/remote/signature.ts22
-rw-r--r--server/middlewares/validators/remote/videos.ts61
4 files changed, 0 insertions, 124 deletions
diff --git a/server/middlewares/validators/remote/index.ts b/server/middlewares/validators/remote/index.ts
deleted file mode 100644
index f1f26043e..000000000
--- a/server/middlewares/validators/remote/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
1export * from './pods'
2export * from './signature'
3export * from './videos'
diff --git a/server/middlewares/validators/remote/pods.ts b/server/middlewares/validators/remote/pods.ts
deleted file mode 100644
index f917b61ee..000000000
--- a/server/middlewares/validators/remote/pods.ts
+++ /dev/null
@@ -1,38 +0,0 @@
1import { body } from 'express-validator/check'
2import * as express from 'express'
3
4import { database as db } from '../../../initializers'
5import { isHostValid, logger } from '../../../helpers'
6import { checkErrors } from '../utils'
7
8const remotePodsAddValidator = [
9 body('host').custom(isHostValid).withMessage('Should have a host'),
10 body('email').isEmail().withMessage('Should have an email'),
11 body('publicKey').not().isEmpty().withMessage('Should have a public key'),
12
13 (req: express.Request, res: express.Response, next: express.NextFunction) => {
14 logger.debug('Checking podsAdd parameters', { parameters: req.body })
15
16 checkErrors(req, res, () => {
17 db.Pod.loadByHost(req.body.host)
18 .then(pod => {
19 // Pod with this host already exists
20 if (pod) {
21 return res.sendStatus(409)
22 }
23
24 return next()
25 })
26 .catch(err => {
27 logger.error('Cannot load pod by host.', err)
28 res.sendStatus(500)
29 })
30 })
31 }
32]
33
34// ---------------------------------------------------------------------------
35
36export {
37 remotePodsAddValidator
38}
diff --git a/server/middlewares/validators/remote/signature.ts b/server/middlewares/validators/remote/signature.ts
deleted file mode 100644
index d3937b515..000000000
--- a/server/middlewares/validators/remote/signature.ts
+++ /dev/null
@@ -1,22 +0,0 @@
1import { body } from 'express-validator/check'
2import * as express from 'express'
3
4import { logger, isHostValid } from '../../../helpers'
5import { checkErrors } from '../utils'
6
7const signatureValidator = [
8 body('signature.host').custom(isHostValid).withMessage('Should have a signature host'),
9 body('signature.signature').not().isEmpty().withMessage('Should have a signature'),
10
11 (req: express.Request, res: express.Response, next: express.NextFunction) => {
12 logger.debug('Checking signature parameters', { parameters: { signature: req.body.signature } })
13
14 checkErrors(req, res, next)
15 }
16]
17
18// ---------------------------------------------------------------------------
19
20export {
21 signatureValidator
22}
diff --git a/server/middlewares/validators/remote/videos.ts b/server/middlewares/validators/remote/videos.ts
deleted file mode 100644
index 497320cc1..000000000
--- a/server/middlewares/validators/remote/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}