diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-04-26 21:42:36 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-04-26 21:42:36 +0200 |
commit | ab683a8e0d998cfd9dfb9562d3c616f3e6e1dbfd (patch) | |
tree | 8f6d77c733b56a3778156eb717b188a1addc7676 /server/middlewares/validators | |
parent | 32502eda29f67ef111391d751f61132f8103fda8 (diff) | |
download | PeerTube-ab683a8e0d998cfd9dfb9562d3c616f3e6e1dbfd.tar.gz PeerTube-ab683a8e0d998cfd9dfb9562d3c616f3e6e1dbfd.tar.zst PeerTube-ab683a8e0d998cfd9dfb9562d3c616f3e6e1dbfd.zip |
Format video blacklist
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r-- | server/middlewares/validators/videos.js | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/server/middlewares/validators/videos.js b/server/middlewares/validators/videos.js index 86a7e39ae..f18ca1597 100644 --- a/server/middlewares/validators/videos.js +++ b/server/middlewares/validators/videos.js | |||
@@ -137,6 +137,18 @@ function videoRate (req, res, next) { | |||
137 | }) | 137 | }) |
138 | } | 138 | } |
139 | 139 | ||
140 | function videosBlacklist (req, res, next) { | ||
141 | req.checkParams('id', 'Should have a valid id').notEmpty().isUUID(4) | ||
142 | |||
143 | logger.debug('Checking videosBlacklist parameters', { parameters: req.params }) | ||
144 | |||
145 | checkErrors(req, res, function () { | ||
146 | checkVideoExists(req.params.id, res, function () { | ||
147 | checkVideoIsBlacklistable(req, res, next) | ||
148 | }) | ||
149 | }) | ||
150 | } | ||
151 | |||
140 | // --------------------------------------------------------------------------- | 152 | // --------------------------------------------------------------------------- |
141 | 153 | ||
142 | module.exports = validatorsVideos | 154 | module.exports = validatorsVideos |
@@ -166,8 +178,8 @@ function checkUserCanDeleteVideo (userId, res, callback) { | |||
166 | } | 178 | } |
167 | 179 | ||
168 | // Check if the user can delete the video | 180 | // Check if the user can delete the video |
169 | // The user can delete it if s/he an admin | 181 | // The user can delete it if s/he is an admin |
170 | // Or if s/he is the video's author | 182 | // Or if s/he is the video's author |
171 | if (user.isAdmin() === false) { | 183 | if (user.isAdmin() === false) { |
172 | if (res.locals.video.isOwned() === false) { | 184 | if (res.locals.video.isOwned() === false) { |
173 | return res.status(403).send('Cannot remove video of another pod') | 185 | return res.status(403).send('Cannot remove video of another pod') |
@@ -185,20 +197,8 @@ function checkUserCanDeleteVideo (userId, res, callback) { | |||
185 | 197 | ||
186 | function checkVideoIsBlacklistable (req, res, callback) { | 198 | function checkVideoIsBlacklistable (req, res, callback) { |
187 | if (res.locals.video.isOwned() === true) { | 199 | if (res.locals.video.isOwned() === true) { |
188 | return res.status(403).send('Cannot blacklist a local video') | 200 | return res.status(403).send('Cannot blacklist a local video') |
189 | } | 201 | } |
190 | 202 | ||
191 | callback() | 203 | callback() |
192 | } | 204 | } |
193 | |||
194 | function videosBlacklist (req, res, next) { | ||
195 | req.checkParams('id', 'Should have a valid id').notEmpty().isUUID(4) | ||
196 | |||
197 | logger.debug('Checking videosBlacklist parameters', { parameters: req.params }) | ||
198 | |||
199 | checkErrors(req, res, function () { | ||
200 | checkVideoExists(req.params.id, res, function() { | ||
201 | checkVideoIsBlacklistable(req, res, next) | ||
202 | }) | ||
203 | }) | ||
204 | } | ||