From 22a73cb879a5cc775d4bec3d72fa9c9cf52e5175 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 12 Dec 2019 15:47:47 +0100 Subject: Add internal privacy mode --- server/middlewares/validators/videos/videos.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'server/middlewares/validators') diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts index ab984d84a..5e0182cc3 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts @@ -161,18 +161,15 @@ const videosCustomGetValidator = (fetchType: 'all' | 'only-video' | 'only-video- const videoAll = video as MVideoFullLight // Video private or blacklisted - if (video.privacy === VideoPrivacy.PRIVATE || videoAll.VideoBlacklist) { + if (videoAll.requiresAuth()) { await authenticatePromiseIfNeeded(req, res, authenticateInQuery) const user = res.locals.oauth ? res.locals.oauth.token.User : null // Only the owner or a user that have blacklist rights can see the video - if ( - !user || - (videoAll.VideoChannel && videoAll.VideoChannel.Account.userId !== user.id && !user.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)) - ) { + if (!user || !user.canGetVideo(videoAll)) { return res.status(403) - .json({ error: 'Cannot get this private or blacklisted video.' }) + .json({ error: 'Cannot get this private/internal or blacklisted video.' }) } return next() -- cgit v1.2.3