- checkErrors(req, res, () => {
- checkVideoChannelExists(req.params.id, res, () => {
- // We need to make additional checks
- if (res.locals.videoChannel.isOwned() === false) {
- return res.status(403)
- .json({ error: 'Cannot update video channel of another server' })
- .end()
- }
-
- if (res.locals.videoChannel.Account.userId !== res.locals.oauth.token.User.id) {
- return res.status(403)
- .json({ error: 'Cannot update video channel of another user' })
- .end()
- }
-
- next()
- })
- })
+ if (areValidationErrors(req, res)) return
+ if (!await isVideoChannelExist(req.params.id, res)) return
+
+ // We need to make additional checks
+ if (res.locals.videoChannel.Actor.isOwned() === false) {
+ return res.status(403)
+ .json({ error: 'Cannot update video channel of another server' })
+ .end()
+ }
+
+ if (res.locals.videoChannel.Account.userId !== res.locals.oauth.token.User.id) {
+ return res.status(403)
+ .json({ error: 'Cannot update video channel of another user' })
+ .end()
+ }
+
+ return next()