aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/feeds.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators/feeds.ts')
-rw-r--r--server/middlewares/validators/feeds.ts11
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 @@
1import * as express from 'express' 1import * as express from 'express'
2import { param, query } from 'express-validator/check' 2import { param, query } from 'express-validator/check'
3import { isAccountIdExist, isAccountNameValid } from '../../helpers/custom-validators/accounts' 3import { isAccountIdExist, isAccountNameValid, isAccountNameWithHostExist } from '../../helpers/custom-validators/accounts'
4import { join } from 'path'
5import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' 4import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
6import { logger } from '../../helpers/logger' 5import { logger } from '../../helpers/logger'
7import { areValidationErrors } from './utils' 6import { areValidationErrors } from './utils'
8import { isValidRSSFeed } from '../../helpers/custom-validators/feeds' 7import { isValidRSSFeed } from '../../helpers/custom-validators/feeds'
9import { isVideoChannelExist } from '../../helpers/custom-validators/video-channels' 8import { isVideoChannelIdExist, isVideoChannelNameWithHostExist } from '../../helpers/custom-validators/video-channels'
10import { isVideoExist } from '../../helpers/custom-validators/videos' 9import { isVideoExist } from '../../helpers/custom-validators/videos'
10import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor'
11 11
12const videoFeedsValidator = [ 12const 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 }