diff options
author | Chocobozzz <me@florianbigard.com> | 2022-08-17 14:27:04 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-08-17 14:27:04 +0200 |
commit | 396f6f0140b0f76162e2378fd5a61e2f888673ed (patch) | |
tree | a5bd668bfc7dca7f311b9fc42ebb8bd01f462648 /server/middlewares/validators/feeds.ts | |
parent | 97eba003a9d0adcb0cab9190f566327b1417c7d3 (diff) | |
download | PeerTube-396f6f0140b0f76162e2378fd5a61e2f888673ed.tar.gz PeerTube-396f6f0140b0f76162e2378fd5a61e2f888673ed.tar.zst PeerTube-396f6f0140b0f76162e2378fd5a61e2f888673ed.zip |
Cleanup useless express validator messages
Diffstat (limited to 'server/middlewares/validators/feeds.ts')
-rw-r--r-- | server/middlewares/validators/feeds.ts | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/server/middlewares/validators/feeds.ts b/server/middlewares/validators/feeds.ts index 04b4e00c9..900c1d383 100644 --- a/server/middlewares/validators/feeds.ts +++ b/server/middlewares/validators/feeds.ts | |||
@@ -16,8 +16,20 @@ import { | |||
16 | } from './shared' | 16 | } from './shared' |
17 | 17 | ||
18 | const feedsFormatValidator = [ | 18 | const feedsFormatValidator = [ |
19 | param('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'), | 19 | param('format') |
20 | query('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)') | 20 | .optional() |
21 | .custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'), | ||
22 | query('format') | ||
23 | .optional() | ||
24 | .custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'), | ||
25 | |||
26 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
27 | logger.debug('Checking feeds format parameters', { parameters: req.query }) | ||
28 | |||
29 | if (areValidationErrors(req, res)) return | ||
30 | |||
31 | return next() | ||
32 | } | ||
21 | ] | 33 | ] |
22 | 34 | ||
23 | function setFeedFormatContentType (req: express.Request, res: express.Response, next: express.NextFunction) { | 35 | function setFeedFormatContentType (req: express.Request, res: express.Response, next: express.NextFunction) { |
@@ -49,16 +61,14 @@ function setFeedFormatContentType (req: express.Request, res: express.Response, | |||
49 | const videoFeedsValidator = [ | 61 | const videoFeedsValidator = [ |
50 | query('accountId') | 62 | query('accountId') |
51 | .optional() | 63 | .optional() |
52 | .custom(isIdValid) | 64 | .custom(isIdValid), |
53 | .withMessage('Should have a valid account id'), | ||
54 | 65 | ||
55 | query('accountName') | 66 | query('accountName') |
56 | .optional(), | 67 | .optional(), |
57 | 68 | ||
58 | query('videoChannelId') | 69 | query('videoChannelId') |
59 | .optional() | 70 | .optional() |
60 | .custom(isIdValid) | 71 | .custom(isIdValid), |
61 | .withMessage('Should have a valid channel id'), | ||
62 | 72 | ||
63 | query('videoChannelName') | 73 | query('videoChannelName') |
64 | .optional(), | 74 | .optional(), |
@@ -79,12 +89,10 @@ const videoFeedsValidator = [ | |||
79 | 89 | ||
80 | const videoSubscriptionFeedsValidator = [ | 90 | const videoSubscriptionFeedsValidator = [ |
81 | query('accountId') | 91 | query('accountId') |
82 | .custom(isIdValid) | 92 | .custom(isIdValid), |
83 | .withMessage('Should have a valid account id'), | ||
84 | 93 | ||
85 | query('token') | 94 | query('token') |
86 | .custom(exists) | 95 | .custom(exists), |
87 | .withMessage('Should have a token'), | ||
88 | 96 | ||
89 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 97 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
90 | logger.debug('Checking subscription feeds parameters', { parameters: req.query }) | 98 | logger.debug('Checking subscription feeds parameters', { parameters: req.query }) |
@@ -100,8 +108,8 @@ const videoSubscriptionFeedsValidator = [ | |||
100 | 108 | ||
101 | const videoCommentsFeedsValidator = [ | 109 | const videoCommentsFeedsValidator = [ |
102 | query('videoId') | 110 | query('videoId') |
103 | .customSanitizer(toCompleteUUID) | ||
104 | .optional() | 111 | .optional() |
112 | .customSanitizer(toCompleteUUID) | ||
105 | .custom(isIdOrUUIDValid), | 113 | .custom(isIdOrUUIDValid), |
106 | 114 | ||
107 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 115 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |