From f1c70a8666e53414f4e604290d35d26ae725b691 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 28 Feb 2022 16:04:31 +0100 Subject: Remove unnecessary code --- server/middlewares/validators/videos/video-comments.ts | 14 ++------------ server/middlewares/validators/videos/video-rates.ts | 7 +------ 2 files changed, 3 insertions(+), 18 deletions(-) (limited to 'server/middlewares/validators/videos') diff --git a/server/middlewares/validators/videos/video-comments.ts b/server/middlewares/validators/videos/video-comments.ts index 96d956035..698afdbd1 100644 --- a/server/middlewares/validators/videos/video-comments.ts +++ b/server/middlewares/validators/videos/video-comments.ts @@ -91,12 +91,7 @@ const addVideoCommentThreadValidator = [ if (areValidationErrors(req, res)) return if (!await doesVideoExist(req.params.videoId, res)) return - if (!await checkCanSeeVideoIfPrivate(req, res, res.locals.videoAll)) { - return res.fail({ - status: HttpStatusCode.FORBIDDEN_403, - message: 'Cannot access to this ressource' - }) - } + if (!await checkCanSeeVideoIfPrivate(req, res, res.locals.videoAll)) return if (!isVideoCommentsEnabled(res.locals.videoAll, res)) return if (!await isVideoCommentAccepted(req, res, res.locals.videoAll, false)) return @@ -118,12 +113,7 @@ const addVideoCommentReplyValidator = [ if (areValidationErrors(req, res)) return if (!await doesVideoExist(req.params.videoId, res)) return - if (!await checkCanSeeVideoIfPrivate(req, res, res.locals.videoAll)) { - return res.fail({ - status: HttpStatusCode.FORBIDDEN_403, - message: 'Cannot access to this ressource' - }) - } + if (!await checkCanSeeVideoIfPrivate(req, res, res.locals.videoAll)) return if (!isVideoCommentsEnabled(res.locals.videoAll, res)) return if (!await doesVideoCommentExist(req.params.commentId, res.locals.videoAll, res)) return diff --git a/server/middlewares/validators/videos/video-rates.ts b/server/middlewares/validators/videos/video-rates.ts index 923bf3eaf..1a9736034 100644 --- a/server/middlewares/validators/videos/video-rates.ts +++ b/server/middlewares/validators/videos/video-rates.ts @@ -21,12 +21,7 @@ const videoUpdateRateValidator = [ if (areValidationErrors(req, res)) return if (!await doesVideoExist(req.params.id, res)) return - if (!await checkCanSeeVideoIfPrivate(req, res, res.locals.videoAll)) { - return res.fail({ - status: HttpStatusCode.FORBIDDEN_403, - message: 'Cannot access to this ressource' - }) - } + if (!await checkCanSeeVideoIfPrivate(req, res, res.locals.videoAll)) return return next() } -- cgit v1.2.3