diff options
Diffstat (limited to 'server/middlewares/validators/pods.ts')
-rw-r--r-- | server/middlewares/validators/pods.ts | 29 |
1 files changed, 1 insertions, 28 deletions
diff --git a/server/middlewares/validators/pods.ts b/server/middlewares/validators/pods.ts index ab7702e78..575c36526 100644 --- a/server/middlewares/validators/pods.ts +++ b/server/middlewares/validators/pods.ts | |||
@@ -3,7 +3,7 @@ import * as express from 'express' | |||
3 | 3 | ||
4 | import { database as db } from '../../initializers/database' | 4 | import { database as db } from '../../initializers/database' |
5 | import { checkErrors } from './utils' | 5 | import { checkErrors } from './utils' |
6 | import { logger, isEachUniqueHostValid, isHostValid } from '../../helpers' | 6 | import { logger, isEachUniqueHostValid } from '../../helpers' |
7 | import { CONFIG } from '../../initializers' | 7 | import { CONFIG } from '../../initializers' |
8 | import { hasFriends } from '../../lib' | 8 | import { hasFriends } from '../../lib' |
9 | import { isTestInstance } from '../../helpers' | 9 | import { isTestInstance } from '../../helpers' |
@@ -41,32 +41,6 @@ const makeFriendsValidator = [ | |||
41 | } | 41 | } |
42 | ] | 42 | ] |
43 | 43 | ||
44 | const podsAddValidator = [ | ||
45 | body('host').custom(isHostValid).withMessage('Should have a host'), | ||
46 | body('email').isEmail().withMessage('Should have an email'), | ||
47 | body('publicKey').not().isEmpty().withMessage('Should have a public key'), | ||
48 | |||
49 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
50 | logger.debug('Checking podsAdd parameters', { parameters: req.body }) | ||
51 | |||
52 | checkErrors(req, res, () => { | ||
53 | db.Pod.loadByHost(req.body.host) | ||
54 | .then(pod => { | ||
55 | // Pod with this host already exists | ||
56 | if (pod) { | ||
57 | return res.sendStatus(409) | ||
58 | } | ||
59 | |||
60 | return next() | ||
61 | }) | ||
62 | .catch(err => { | ||
63 | logger.error('Cannot load pod by host.', err) | ||
64 | res.sendStatus(500) | ||
65 | }) | ||
66 | }) | ||
67 | } | ||
68 | ] | ||
69 | |||
70 | const podRemoveValidator = [ | 44 | const podRemoveValidator = [ |
71 | param('id').isNumeric().not().isEmpty().withMessage('Should have a valid id'), | 45 | param('id').isNumeric().not().isEmpty().withMessage('Should have a valid id'), |
72 | 46 | ||
@@ -96,6 +70,5 @@ const podRemoveValidator = [ | |||
96 | 70 | ||
97 | export { | 71 | export { |
98 | makeFriendsValidator, | 72 | makeFriendsValidator, |
99 | podsAddValidator, | ||
100 | podRemoveValidator | 73 | podRemoveValidator |
101 | } | 74 | } |