aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-06-08 20:34:37 +0200
committerChocobozzz <me@florianbigard.com>2018-06-08 20:34:37 +0200
commitfe3a55b071c99b346e9e9ab786f5d219e5a064cd (patch)
tree55c6d0e9a253b20df738fd82820eb931044828e6 /server/middlewares
parent4a7591e1a8ec5ffdff85580c6be4b18d8b85b4d4 (diff)
downloadPeerTube-fe3a55b071c99b346e9e9ab786f5d219e5a064cd.tar.gz
PeerTube-fe3a55b071c99b346e9e9ab786f5d219e5a064cd.tar.zst
PeerTube-fe3a55b071c99b346e9e9ab786f5d219e5a064cd.zip
Add video comments RSS
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/validators/feeds.ts23
1 files changed, 21 insertions, 2 deletions
diff --git a/server/middlewares/validators/feeds.ts b/server/middlewares/validators/feeds.ts
index b55190559..3c8532bd9 100644
--- a/server/middlewares/validators/feeds.ts
+++ b/server/middlewares/validators/feeds.ts
@@ -7,12 +7,14 @@ import { logger } from '../../helpers/logger'
7import { areValidationErrors } from './utils' 7import { areValidationErrors } from './utils'
8import { isValidRSSFeed } from '../../helpers/custom-validators/feeds' 8import { isValidRSSFeed } from '../../helpers/custom-validators/feeds'
9import { isVideoChannelExist } from '../../helpers/custom-validators/video-channels' 9import { isVideoChannelExist } from '../../helpers/custom-validators/video-channels'
10import { isVideoExist } from '../../helpers/custom-validators/videos'
10 11
11const feedsValidator = [ 12const videoFeedsValidator = [
12 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)'),
13 query('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'), 14 query('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'),
14 query('accountId').optional().custom(isIdOrUUIDValid), 15 query('accountId').optional().custom(isIdOrUUIDValid),
15 query('accountName').optional().custom(isAccountNameValid), 16 query('accountName').optional().custom(isAccountNameValid),
17 query('videoChannelId').optional().custom(isIdOrUUIDValid),
16 18
17 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 19 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
18 logger.debug('Checking feeds parameters', { parameters: req.query }) 20 logger.debug('Checking feeds parameters', { parameters: req.query })
@@ -26,8 +28,25 @@ const feedsValidator = [
26 } 28 }
27] 29]
28 30
31const videoCommentsFeedsValidator = [
32 param('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'),
33 query('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'),
34 query('videoId').optional().custom(isIdOrUUIDValid),
35
36 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
37 logger.debug('Checking feeds parameters', { parameters: req.query })
38
39 if (areValidationErrors(req, res)) return
40
41 if (req.query.videoId && !await isVideoExist(req.query.videoId, res)) return
42
43 return next()
44 }
45]
46
29// --------------------------------------------------------------------------- 47// ---------------------------------------------------------------------------
30 48
31export { 49export {
32 feedsValidator 50 videoFeedsValidator,
51 videoCommentsFeedsValidator
33} 52}