doesAccountIdExist,
doesAccountNameWithHostExist,
doesVideoChannelIdExist,
- doesVideoChannelNameWithHostExist
+ doesVideoChannelNameWithHostExist,
+ doesUserFeedTokenCorrespond
} from '../../helpers/middlewares'
const feedsFormatValidator = [
}
]
+const videoSubscriptonFeedsValidator = [
+ query('accountId').custom(isIdValid),
+ query('token'),
+
+ async (req: express.Request, res: express.Response, next: express.NextFunction) => {
+ logger.debug('Checking feeds parameters', { parameters: req.query })
+
+ if (areValidationErrors(req, res)) return
+
+ // a token alone is erroneous
+ if (req.query.token && !req.query.accountId) return
+ if (req.query.accountId && !await doesAccountIdExist(req.query.accountId, res)) return
+ if (req.query.token && !await doesUserFeedTokenCorrespond(res.locals.account.userId, req.query.token, res)) return
+
+ return next()
+ }
+]
+
const videoCommentsFeedsValidator = [
query('videoId').optional().custom(isIdOrUUIDValid),
feedsFormatValidator,
setFeedFormatContentType,
videoFeedsValidator,
+ videoSubscriptonFeedsValidator,
videoCommentsFeedsValidator
}