'use strict'
-var checkErrors = require('./utils').checkErrors
-var logger = require('../../helpers/logger')
-var Videos = require('../../models/videos')
+const checkErrors = require('./utils').checkErrors
+const logger = require('../../helpers/logger')
+const videos = require('../../lib/videos')
+const Videos = require('../../models/videos')
-var reqValidatorsVideos = {
+const reqValidatorsVideos = {
videosAdd: videosAdd,
videosGet: videosGet,
videosRemove: videosRemove,
logger.debug('Checking videosGet parameters', { parameters: req.params })
checkErrors(req, res, function () {
- Videos.getVideoState(req.params.id, function (err, state) {
+ Videos.get(req.params.id, function (err, video) {
if (err) {
logger.error('Error in videosGet request validator.', { error: err })
res.sendStatus(500)
}
- if (state.exist === false) return res.status(404).send('Video not found')
+ videos.getVideoState(video, function (state) {
+ if (state.exist === false) return res.status(404).send('Video not found')
- next()
+ next()
+ })
})
})
}
logger.debug('Checking videosRemove parameters', { parameters: req.params })
checkErrors(req, res, function () {
- Videos.getVideoState(req.params.id, function (err, state) {
+ Videos.get(req.params.id, function (err, video) {
if (err) {
logger.error('Error in videosRemove request validator.', { error: err })
res.sendStatus(500)
}
- if (state.exist === false) return res.status(404).send('Video not found')
- else if (state.owned === false) return res.status(403).send('Cannot remove video of another pod')
+ videos.getVideoState(video, function (state) {
+ if (state.exist === false) return res.status(404).send('Video not found')
+ else if (state.owned === false) return res.status(403).send('Cannot remove video of another pod')
- next()
+ next()
+ })
})
})
}