diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-16 15:25:20 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-27 09:41:54 +0200 |
commit | 06a05d5f4784a7cbb27aa1188385b5679845dad8 (patch) | |
tree | ac197f3ed0768529456225ad76c912f22bc55e29 /server/middlewares/validators/video-channels.ts | |
parent | 4bda2e47bbc937c401ddcf14c1be53c70481a294 (diff) | |
download | PeerTube-06a05d5f4784a7cbb27aa1188385b5679845dad8.tar.gz PeerTube-06a05d5f4784a7cbb27aa1188385b5679845dad8.tar.zst PeerTube-06a05d5f4784a7cbb27aa1188385b5679845dad8.zip |
Add subscriptions endpoints to REST API
Diffstat (limited to 'server/middlewares/validators/video-channels.ts')
-rw-r--r-- | server/middlewares/validators/video-channels.ts | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/server/middlewares/validators/video-channels.ts b/server/middlewares/validators/video-channels.ts index 143ce9582..d354c7e05 100644 --- a/server/middlewares/validators/video-channels.ts +++ b/server/middlewares/validators/video-channels.ts | |||
@@ -4,6 +4,7 @@ import { UserRight } from '../../../shared' | |||
4 | import { isAccountNameWithHostExist } from '../../helpers/custom-validators/accounts' | 4 | import { isAccountNameWithHostExist } from '../../helpers/custom-validators/accounts' |
5 | import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' | 5 | import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' |
6 | import { | 6 | import { |
7 | isLocalVideoChannelNameExist, | ||
7 | isVideoChannelDescriptionValid, | 8 | isVideoChannelDescriptionValid, |
8 | isVideoChannelExist, | 9 | isVideoChannelExist, |
9 | isVideoChannelNameValid, | 10 | isVideoChannelNameValid, |
@@ -100,6 +101,19 @@ const videoChannelsGetValidator = [ | |||
100 | } | 101 | } |
101 | ] | 102 | ] |
102 | 103 | ||
104 | const localVideoChannelValidator = [ | ||
105 | param('name').custom(isVideoChannelNameValid).withMessage('Should have a valid video channel name'), | ||
106 | |||
107 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
108 | logger.debug('Checking localVideoChannelValidator parameters', { parameters: req.params }) | ||
109 | |||
110 | if (areValidationErrors(req, res)) return | ||
111 | if (!await isLocalVideoChannelNameExist(req.params.name, res)) return | ||
112 | |||
113 | return next() | ||
114 | } | ||
115 | ] | ||
116 | |||
103 | // --------------------------------------------------------------------------- | 117 | // --------------------------------------------------------------------------- |
104 | 118 | ||
105 | export { | 119 | export { |
@@ -107,7 +121,8 @@ export { | |||
107 | videoChannelsAddValidator, | 121 | videoChannelsAddValidator, |
108 | videoChannelsUpdateValidator, | 122 | videoChannelsUpdateValidator, |
109 | videoChannelsRemoveValidator, | 123 | videoChannelsRemoveValidator, |
110 | videoChannelsGetValidator | 124 | videoChannelsGetValidator, |
125 | localVideoChannelValidator | ||
111 | } | 126 | } |
112 | 127 | ||
113 | // --------------------------------------------------------------------------- | 128 | // --------------------------------------------------------------------------- |