diff options
Diffstat (limited to 'server/middlewares/validators/feeds.ts')
-rw-r--r-- | server/middlewares/validators/feeds.ts | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/server/middlewares/validators/feeds.ts b/server/middlewares/validators/feeds.ts index c3de0f5fe..5c76a679f 100644 --- a/server/middlewares/validators/feeds.ts +++ b/server/middlewares/validators/feeds.ts | |||
@@ -9,7 +9,8 @@ import { | |||
9 | doesAccountIdExist, | 9 | doesAccountIdExist, |
10 | doesAccountNameWithHostExist, | 10 | doesAccountNameWithHostExist, |
11 | doesVideoChannelIdExist, | 11 | doesVideoChannelIdExist, |
12 | doesVideoChannelNameWithHostExist | 12 | doesVideoChannelNameWithHostExist, |
13 | doesUserFeedTokenCorrespond | ||
13 | } from '../../helpers/middlewares' | 14 | } from '../../helpers/middlewares' |
14 | 15 | ||
15 | const feedsFormatValidator = [ | 16 | const feedsFormatValidator = [ |
@@ -62,6 +63,23 @@ const videoFeedsValidator = [ | |||
62 | } | 63 | } |
63 | ] | 64 | ] |
64 | 65 | ||
66 | const videoSubscriptonFeedsValidator = [ | ||
67 | query('accountId').optional().custom(isIdValid), | ||
68 | query('token').optional(), | ||
69 | |||
70 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
71 | logger.debug('Checking feeds parameters', { parameters: req.query }) | ||
72 | |||
73 | if (areValidationErrors(req, res)) return | ||
74 | |||
75 | // a token alone is erroneous | ||
76 | if (req.query.token && !req.query.accountId) return | ||
77 | if (req.query.token && !await doesUserFeedTokenCorrespond(res.locals.account.userId, req.query.token, res)) return | ||
78 | |||
79 | return next() | ||
80 | } | ||
81 | ] | ||
82 | |||
65 | const videoCommentsFeedsValidator = [ | 83 | const videoCommentsFeedsValidator = [ |
66 | query('videoId').optional().custom(isIdOrUUIDValid), | 84 | query('videoId').optional().custom(isIdOrUUIDValid), |
67 | 85 | ||
@@ -88,5 +106,6 @@ export { | |||
88 | feedsFormatValidator, | 106 | feedsFormatValidator, |
89 | setFeedFormatContentType, | 107 | setFeedFormatContentType, |
90 | videoFeedsValidator, | 108 | videoFeedsValidator, |
109 | videoSubscriptonFeedsValidator, | ||
91 | videoCommentsFeedsValidator | 110 | videoCommentsFeedsValidator |
92 | } | 111 | } |