diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-23 18:04:48 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:53 +0100 |
commit | d4f1e94c89336255537b0b82913591f00e716201 (patch) | |
tree | c7d18e09a4f53eafc61de8cb0692c020b197512d /server/middlewares | |
parent | 8d468a16fd33ec2660c3c59b3f7def53eb0cc4a1 (diff) | |
download | PeerTube-d4f1e94c89336255537b0b82913591f00e716201.tar.gz PeerTube-d4f1e94c89336255537b0b82913591f00e716201.tar.zst PeerTube-d4f1e94c89336255537b0b82913591f00e716201.zip |
Misc cleanup
Diffstat (limited to 'server/middlewares')
-rw-r--r-- | server/middlewares/servers.ts | 18 | ||||
-rw-r--r-- | server/middlewares/validators/video-channels.ts | 19 |
2 files changed, 8 insertions, 29 deletions
diff --git a/server/middlewares/servers.ts b/server/middlewares/servers.ts index eaf9aa144..488f9c368 100644 --- a/server/middlewares/servers.ts +++ b/server/middlewares/servers.ts | |||
@@ -20,26 +20,10 @@ function setBodyHostsPort (req: express.Request, res: express.Response, next: ex | |||
20 | return next() | 20 | return next() |
21 | } | 21 | } |
22 | 22 | ||
23 | function setBodyHostPort (req: express.Request, res: express.Response, next: express.NextFunction) { | ||
24 | if (!req.body.host) return next() | ||
25 | |||
26 | const hostWithPort = getHostWithPort(req.body.host) | ||
27 | |||
28 | // Problem with the url parsing? | ||
29 | if (hostWithPort === null) { | ||
30 | return res.sendStatus(500) | ||
31 | } | ||
32 | |||
33 | req.body.host = hostWithPort | ||
34 | |||
35 | return next() | ||
36 | } | ||
37 | |||
38 | // --------------------------------------------------------------------------- | 23 | // --------------------------------------------------------------------------- |
39 | 24 | ||
40 | export { | 25 | export { |
41 | setBodyHostsPort, | 26 | setBodyHostsPort |
42 | setBodyHostPort | ||
43 | } | 27 | } |
44 | 28 | ||
45 | // --------------------------------------------------------------------------- | 29 | // --------------------------------------------------------------------------- |
diff --git a/server/middlewares/validators/video-channels.ts b/server/middlewares/validators/video-channels.ts index 0326e05b9..c6fd3b59d 100644 --- a/server/middlewares/validators/video-channels.ts +++ b/server/middlewares/validators/video-channels.ts | |||
@@ -1,18 +1,13 @@ | |||
1 | import { body, param } from 'express-validator/check' | ||
2 | import * as express from 'express' | 1 | import * as express from 'express' |
3 | 2 | import { body, param } from 'express-validator/check' | |
4 | import { checkErrors } from './utils' | 3 | import { UserRight } from '../../../shared' |
4 | import { checkVideoAccountExists } from '../../helpers/custom-validators/accounts' | ||
5 | import { isVideoChannelDescriptionValid, isVideoChannelNameValid } from '../../helpers/custom-validators/video-channels' | ||
6 | import { checkVideoChannelExists, isIdOrUUIDValid } from '../../helpers/index' | ||
7 | import { logger } from '../../helpers/logger' | ||
5 | import { database as db } from '../../initializers' | 8 | import { database as db } from '../../initializers' |
6 | import { | ||
7 | logger, | ||
8 | isIdOrUUIDValid, | ||
9 | isVideoChannelDescriptionValid, | ||
10 | isVideoChannelNameValid, | ||
11 | checkVideoChannelExists, | ||
12 | checkVideoAccountExists | ||
13 | } from '../../helpers' | ||
14 | import { UserInstance } from '../../models' | 9 | import { UserInstance } from '../../models' |
15 | import { UserRight } from '../../../shared' | 10 | import { checkErrors } from './utils' |
16 | 11 | ||
17 | const listVideoAccountChannelsValidator = [ | 12 | const listVideoAccountChannelsValidator = [ |
18 | param('accountId').custom(isIdOrUUIDValid).withMessage('Should have a valid account id'), | 13 | param('accountId').custom(isIdOrUUIDValid).withMessage('Should have a valid account id'), |