diff options
author | Chocobozzz <me@florianbigard.com> | 2022-06-22 09:44:08 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-06-22 10:25:31 +0200 |
commit | ff9d43f62a4f4737c5bfe955883b48c5440f323a (patch) | |
tree | 60593f4b57ec5cd712986a3db370f39b0b7a4cef /server/middlewares/validators/videos/video-comments.ts | |
parent | 2e401e8575decb1d491d0db48ca1ab1eba5b2a66 (diff) | |
download | PeerTube-ff9d43f62a4f4737c5bfe955883b48c5440f323a.tar.gz PeerTube-ff9d43f62a4f4737c5bfe955883b48c5440f323a.tar.zst PeerTube-ff9d43f62a4f4737c5bfe955883b48c5440f323a.zip |
Refactor video rights checker
Diffstat (limited to 'server/middlewares/validators/videos/video-comments.ts')
-rw-r--r-- | server/middlewares/validators/videos/video-comments.ts | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/server/middlewares/validators/videos/video-comments.ts b/server/middlewares/validators/videos/video-comments.ts index 698afdbd1..b22a4e3b7 100644 --- a/server/middlewares/validators/videos/video-comments.ts +++ b/server/middlewares/validators/videos/video-comments.ts | |||
@@ -10,7 +10,7 @@ import { Hooks } from '../../../lib/plugins/hooks' | |||
10 | import { MCommentOwnerVideoReply, MVideo, MVideoFullLight } from '../../../types/models/video' | 10 | import { MCommentOwnerVideoReply, MVideo, MVideoFullLight } from '../../../types/models/video' |
11 | import { | 11 | import { |
12 | areValidationErrors, | 12 | areValidationErrors, |
13 | checkCanSeeVideoIfPrivate, | 13 | checkCanSeeVideo, |
14 | doesVideoCommentExist, | 14 | doesVideoCommentExist, |
15 | doesVideoCommentThreadExist, | 15 | doesVideoCommentThreadExist, |
16 | doesVideoExist, | 16 | doesVideoExist, |
@@ -54,7 +54,7 @@ const listVideoCommentThreadsValidator = [ | |||
54 | if (areValidationErrors(req, res)) return | 54 | if (areValidationErrors(req, res)) return |
55 | if (!await doesVideoExist(req.params.videoId, res, 'only-video')) return | 55 | if (!await doesVideoExist(req.params.videoId, res, 'only-video')) return |
56 | 56 | ||
57 | if (!await checkCanSeeVideoIfPrivate(req, res, res.locals.onlyVideo)) return | 57 | if (!await checkCanSeeVideo({ req, res, paramId: req.params.videoId, video: res.locals.onlyVideo })) return |
58 | 58 | ||
59 | return next() | 59 | return next() |
60 | } | 60 | } |
@@ -73,7 +73,7 @@ const listVideoThreadCommentsValidator = [ | |||
73 | if (!await doesVideoExist(req.params.videoId, res, 'only-video')) return | 73 | if (!await doesVideoExist(req.params.videoId, res, 'only-video')) return |
74 | if (!await doesVideoCommentThreadExist(req.params.threadId, res.locals.onlyVideo, res)) return | 74 | if (!await doesVideoCommentThreadExist(req.params.threadId, res.locals.onlyVideo, res)) return |
75 | 75 | ||
76 | if (!await checkCanSeeVideoIfPrivate(req, res, res.locals.onlyVideo)) return | 76 | if (!await checkCanSeeVideo({ req, res, paramId: req.params.videoId, video: res.locals.onlyVideo })) return |
77 | 77 | ||
78 | return next() | 78 | return next() |
79 | } | 79 | } |
@@ -91,7 +91,7 @@ const addVideoCommentThreadValidator = [ | |||
91 | if (areValidationErrors(req, res)) return | 91 | if (areValidationErrors(req, res)) return |
92 | if (!await doesVideoExist(req.params.videoId, res)) return | 92 | if (!await doesVideoExist(req.params.videoId, res)) return |
93 | 93 | ||
94 | if (!await checkCanSeeVideoIfPrivate(req, res, res.locals.videoAll)) return | 94 | if (!await checkCanSeeVideo({ req, res, paramId: req.params.videoId, video: res.locals.videoAll })) return |
95 | 95 | ||
96 | if (!isVideoCommentsEnabled(res.locals.videoAll, res)) return | 96 | if (!isVideoCommentsEnabled(res.locals.videoAll, res)) return |
97 | if (!await isVideoCommentAccepted(req, res, res.locals.videoAll, false)) return | 97 | if (!await isVideoCommentAccepted(req, res, res.locals.videoAll, false)) return |
@@ -113,7 +113,7 @@ const addVideoCommentReplyValidator = [ | |||
113 | if (areValidationErrors(req, res)) return | 113 | if (areValidationErrors(req, res)) return |
114 | if (!await doesVideoExist(req.params.videoId, res)) return | 114 | if (!await doesVideoExist(req.params.videoId, res)) return |
115 | 115 | ||
116 | if (!await checkCanSeeVideoIfPrivate(req, res, res.locals.videoAll)) return | 116 | if (!await checkCanSeeVideo({ req, res, paramId: req.params.videoId, video: res.locals.videoAll })) return |
117 | 117 | ||
118 | if (!isVideoCommentsEnabled(res.locals.videoAll, res)) return | 118 | if (!isVideoCommentsEnabled(res.locals.videoAll, res)) return |
119 | if (!await doesVideoCommentExist(req.params.commentId, res.locals.videoAll, res)) return | 119 | if (!await doesVideoCommentExist(req.params.commentId, res.locals.videoAll, res)) return |