diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-17 15:45:42 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-27 09:41:54 +0200 |
commit | 8a19bee1a1ee39f973bb37429e4f73c3f2873cdb (patch) | |
tree | 33c93ef19451d7e46d4be74ce0681359d2dcc70e /server/middlewares/validators/feeds.ts | |
parent | 965c4b22d0e4d2f853501e844e6ebbb861bd389d (diff) | |
download | PeerTube-8a19bee1a1ee39f973bb37429e4f73c3f2873cdb.tar.gz PeerTube-8a19bee1a1ee39f973bb37429e4f73c3f2873cdb.tar.zst PeerTube-8a19bee1a1ee39f973bb37429e4f73c3f2873cdb.zip |
Add ability to set a name to a channel
Diffstat (limited to 'server/middlewares/validators/feeds.ts')
-rw-r--r-- | server/middlewares/validators/feeds.ts | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/server/middlewares/validators/feeds.ts b/server/middlewares/validators/feeds.ts index 3c8532bd9..c1054ad9b 100644 --- a/server/middlewares/validators/feeds.ts +++ b/server/middlewares/validators/feeds.ts | |||
@@ -1,13 +1,13 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { param, query } from 'express-validator/check' | 2 | import { param, query } from 'express-validator/check' |
3 | import { isAccountIdExist, isAccountNameValid } from '../../helpers/custom-validators/accounts' | 3 | import { isAccountIdExist, isAccountNameValid, isAccountNameWithHostExist } from '../../helpers/custom-validators/accounts' |
4 | import { join } from 'path' | ||
5 | import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' | 4 | import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' |
6 | import { logger } from '../../helpers/logger' | 5 | import { logger } from '../../helpers/logger' |
7 | import { areValidationErrors } from './utils' | 6 | import { areValidationErrors } from './utils' |
8 | import { isValidRSSFeed } from '../../helpers/custom-validators/feeds' | 7 | import { isValidRSSFeed } from '../../helpers/custom-validators/feeds' |
9 | import { isVideoChannelExist } from '../../helpers/custom-validators/video-channels' | 8 | import { isVideoChannelIdExist, isVideoChannelNameWithHostExist } from '../../helpers/custom-validators/video-channels' |
10 | import { isVideoExist } from '../../helpers/custom-validators/videos' | 9 | import { isVideoExist } from '../../helpers/custom-validators/videos' |
10 | import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor' | ||
11 | 11 | ||
12 | const videoFeedsValidator = [ | 12 | const videoFeedsValidator = [ |
13 | param('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'), | 13 | param('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'), |
@@ -15,6 +15,7 @@ const videoFeedsValidator = [ | |||
15 | query('accountId').optional().custom(isIdOrUUIDValid), | 15 | query('accountId').optional().custom(isIdOrUUIDValid), |
16 | query('accountName').optional().custom(isAccountNameValid), | 16 | query('accountName').optional().custom(isAccountNameValid), |
17 | query('videoChannelId').optional().custom(isIdOrUUIDValid), | 17 | query('videoChannelId').optional().custom(isIdOrUUIDValid), |
18 | query('videoChannelName').optional().custom(isActorPreferredUsernameValid), | ||
18 | 19 | ||
19 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 20 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
20 | logger.debug('Checking feeds parameters', { parameters: req.query }) | 21 | logger.debug('Checking feeds parameters', { parameters: req.query }) |
@@ -22,7 +23,9 @@ const videoFeedsValidator = [ | |||
22 | if (areValidationErrors(req, res)) return | 23 | if (areValidationErrors(req, res)) return |
23 | 24 | ||
24 | if (req.query.accountId && !await isAccountIdExist(req.query.accountId, res)) return | 25 | if (req.query.accountId && !await isAccountIdExist(req.query.accountId, res)) return |
25 | if (req.query.videoChannelId && !await isVideoChannelExist(req.query.videoChannelId, res)) return | 26 | if (req.query.videoChannelName && !await isVideoChannelIdExist(req.query.videoChannelName, res)) return |
27 | if (req.query.accountName && !await isAccountNameWithHostExist(req.query.accountName, res)) return | ||
28 | if (req.query.videoChannelName && !await isVideoChannelNameWithHostExist(req.query.videoChannelName, res)) return | ||
26 | 29 | ||
27 | return next() | 30 | return next() |
28 | } | 31 | } |