diff options
author | Chocobozzz <me@florianbigard.com> | 2019-03-19 10:35:15 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-03-19 10:35:15 +0100 |
commit | dae86118ed5d4026d04acb9d0e36829b9ad8eb4e (patch) | |
tree | a5bf9c4487240bf75a9b328cad459a0587f90dea /server/middlewares/validators/videos/videos.ts | |
parent | e65c0c5b1fab9c3d93f51721b2458cf5cf471f20 (diff) | |
download | PeerTube-dae86118ed5d4026d04acb9d0e36829b9ad8eb4e.tar.gz PeerTube-dae86118ed5d4026d04acb9d0e36829b9ad8eb4e.tar.zst PeerTube-dae86118ed5d4026d04acb9d0e36829b9ad8eb4e.zip |
Cleanup express locals typings
Diffstat (limited to 'server/middlewares/validators/videos/videos.ts')
-rw-r--r-- | server/middlewares/validators/videos/videos.ts | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts index 92218d4b1..b70abf429 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts | |||
@@ -130,7 +130,7 @@ const videosUpdateValidator = getCommonVideoEditAttributes().concat([ | |||
130 | ]) | 130 | ]) |
131 | 131 | ||
132 | async function checkVideoFollowConstraints (req: express.Request, res: express.Response, next: express.NextFunction) { | 132 | async function checkVideoFollowConstraints (req: express.Request, res: express.Response, next: express.NextFunction) { |
133 | const video: VideoModel = res.locals.video | 133 | const video = res.locals.video |
134 | 134 | ||
135 | // Anybody can watch local videos | 135 | // Anybody can watch local videos |
136 | if (video.isOwned() === true) return next() | 136 | if (video.isOwned() === true) return next() |
@@ -164,13 +164,13 @@ const videosCustomGetValidator = (fetchType: VideoFetchType) => { | |||
164 | if (areValidationErrors(req, res)) return | 164 | if (areValidationErrors(req, res)) return |
165 | if (!await doesVideoExist(req.params.id, res, fetchType)) return | 165 | if (!await doesVideoExist(req.params.id, res, fetchType)) return |
166 | 166 | ||
167 | const video: VideoModel = res.locals.video | 167 | const video = res.locals.video |
168 | 168 | ||
169 | // Video private or blacklisted | 169 | // Video private or blacklisted |
170 | if (video.privacy === VideoPrivacy.PRIVATE || video.VideoBlacklist) { | 170 | if (video.privacy === VideoPrivacy.PRIVATE || video.VideoBlacklist) { |
171 | await authenticatePromiseIfNeeded(req, res) | 171 | await authenticatePromiseIfNeeded(req, res) |
172 | 172 | ||
173 | const user: UserModel = res.locals.oauth ? res.locals.oauth.token.User : null | 173 | const user = res.locals.oauth ? res.locals.oauth.token.User : null |
174 | 174 | ||
175 | // Only the owner or a user that have blacklist rights can see the video | 175 | // Only the owner or a user that have blacklist rights can see the video |
176 | if ( | 176 | if ( |
@@ -256,7 +256,7 @@ const videosTerminateChangeOwnershipValidator = [ | |||
256 | return next() | 256 | return next() |
257 | }, | 257 | }, |
258 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 258 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
259 | const videoChangeOwnership = res.locals.videoChangeOwnership as VideoChangeOwnershipModel | 259 | const videoChangeOwnership = res.locals.videoChangeOwnership |
260 | 260 | ||
261 | if (videoChangeOwnership.status === VideoChangeOwnershipStatus.WAITING) { | 261 | if (videoChangeOwnership.status === VideoChangeOwnershipStatus.WAITING) { |
262 | return next() | 262 | return next() |
@@ -275,7 +275,7 @@ const videosAcceptChangeOwnershipValidator = [ | |||
275 | if (!await doesVideoChannelOfAccountExist(body.channelId, res.locals.oauth.token.User, res)) return | 275 | if (!await doesVideoChannelOfAccountExist(body.channelId, res.locals.oauth.token.User, res)) return |
276 | 276 | ||
277 | const user = res.locals.oauth.token.User | 277 | const user = res.locals.oauth.token.User |
278 | const videoChangeOwnership = res.locals.videoChangeOwnership as VideoChangeOwnershipModel | 278 | const videoChangeOwnership = res.locals.videoChangeOwnership |
279 | const isAble = await user.isAbleToUploadVideo(videoChangeOwnership.Video.getOriginalFile()) | 279 | const isAble = await user.isAbleToUploadVideo(videoChangeOwnership.Video.getOriginalFile()) |
280 | if (isAble === false) { | 280 | if (isAble === false) { |
281 | res.status(403) | 281 | res.status(403) |
@@ -395,7 +395,7 @@ const commonVideosFiltersValidator = [ | |||
395 | 395 | ||
396 | if (areValidationErrors(req, res)) return | 396 | if (areValidationErrors(req, res)) return |
397 | 397 | ||
398 | const user: UserModel = res.locals.oauth ? res.locals.oauth.token.User : undefined | 398 | const user = res.locals.oauth ? res.locals.oauth.token.User : undefined |
399 | if (req.query.filter === 'all-local' && (!user || user.hasRight(UserRight.SEE_ALL_VIDEOS) === false)) { | 399 | if (req.query.filter === 'all-local' && (!user || user.hasRight(UserRight.SEE_ALL_VIDEOS) === false)) { |
400 | res.status(401) | 400 | res.status(401) |
401 | .json({ error: 'You are not allowed to see all local videos.' }) | 401 | .json({ error: 'You are not allowed to see all local videos.' }) |