- if (req.query.accountId) {
- if (!await isAccountIdExist(req.query.accountId, res)) return
- } else if (req.query.accountName) {
- if (!await isLocalAccountNameExist(req.query.accountName, res)) return
+ if (req.query.accountId && !await doesAccountIdExist(req.query.accountId, res)) return
+ if (req.query.videoChannelId && !await doesVideoChannelIdExist(req.query.videoChannelId, res)) return
+ if (req.query.accountName && !await doesAccountNameWithHostExist(req.query.accountName, res)) return
+ if (req.query.videoChannelName && !await doesVideoChannelNameWithHostExist(req.query.videoChannelName, res)) return
+
+ return next()
+ }
+]
+
+const videoSubscriptionFeedsValidator = [
+ query('accountId')
+ .custom(isIdValid)
+ .withMessage('Should have a valid account id'),
+
+ query('token')
+ .custom(exists)
+ .withMessage('Should have a token'),
+
+ async (req: express.Request, res: express.Response, next: express.NextFunction) => {
+ logger.debug('Checking subscription feeds parameters', { parameters: req.query })
+
+ if (areValidationErrors(req, res)) return
+
+ if (!await doesAccountIdExist(req.query.accountId, res)) return
+ if (!await doesUserFeedTokenCorrespond(res.locals.account.userId, req.query.token, res)) return
+
+ return next()
+ }
+]
+
+const videoCommentsFeedsValidator = [
+ query('videoId')
+ .customSanitizer(toCompleteUUID)
+ .optional()
+ .custom(isIdOrUUIDValid),
+
+ async (req: express.Request, res: express.Response, next: express.NextFunction) => {
+ logger.debug('Checking feeds parameters', { parameters: req.query })
+
+ if (areValidationErrors(req, res)) return
+
+ if (req.query.videoId && (req.query.videoChannelId || req.query.videoChannelName)) {
+ return res.fail({ message: 'videoId cannot be mixed with a channel filter' })