aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r--server/middlewares/validators/videos.js30
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
140function 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
142module.exports = validatorsVideos 154module.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
186function checkVideoIsBlacklistable (req, res, callback) { 198function 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
194function 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}