X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=server%2Fcontrollers%2Fapi%2Fvideos.js;h=35d6979e5ecd483daf72cb9302454a2f439e14ab;hb=818f7987eba27c59793e2103168b26129c9404f2;hp=e5c52a87b4f0c9ba670b7f6f88efc8f2e39328b2;hpb=79066fdf33f79d2d41394f10881e2c226ca26b49;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/api/videos.js b/server/controllers/api/videos.js index e5c52a87b..35d6979e5 100644 --- a/server/controllers/api/videos.js +++ b/server/controllers/api/videos.js @@ -200,7 +200,7 @@ function addVideo (req, res, next) { } function updateVideo (req, res, next) { - let videoInstance = res.locals.video + const videoInstance = res.locals.video const videoInfosToUpdate = req.body waterfall([ @@ -275,15 +275,8 @@ function updateVideo (req, res, next) { } function getVideo (req, res, next) { - db.Video.loadAndPopulateAuthorAndPodAndTags(req.params.id, function (err, video) { - if (err) return next(err) - - if (!video) { - return res.type('json').status(204).end() - } - - res.json(video.toFormatedJSON()) - }) + const videoInstance = res.locals.video + res.json(videoInstance.toFormatedJSON()) } function listVideos (req, res, next) { @@ -295,20 +288,9 @@ function listVideos (req, res, next) { } function removeVideo (req, res, next) { - const videoId = req.params.id + const videoInstance = res.locals.video - waterfall([ - function loadVideo (callback) { - db.Video.load(videoId, function (err, video) { - return callback(err, video) - }) - }, - - function deleteVideo (video, callback) { - // Informations to other pods will be sent by the afterDestroy video hook - video.destroy().asCallback(callback) - } - ], function andFinally (err) { + videoInstance.destroy().asCallback(function (err) { if (err) { logger.error('Errors when removed the video.', { error: err }) return next(err)