From 6e07c3de88791a0b342e0cc319590048117f9c2d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 22 Mar 2017 21:15:55 +0100 Subject: Add video category support --- server/controllers/api/remote/videos.js | 2 ++ server/controllers/api/videos.js | 8 ++++++++ 2 files changed, 10 insertions(+) (limited to 'server/controllers') diff --git a/server/controllers/api/remote/videos.js b/server/controllers/api/remote/videos.js index cbd58e0e4..c8ef0c445 100644 --- a/server/controllers/api/remote/videos.js +++ b/server/controllers/api/remote/videos.js @@ -294,6 +294,7 @@ function addRemoteVideo (videoToCreateData, fromPod, finalCallback) { remoteId: videoToCreateData.remoteId, extname: videoToCreateData.extname, infoHash: videoToCreateData.infoHash, + category: videoToCreateData.category, description: videoToCreateData.description, authorId: author.id, duration: videoToCreateData.duration, @@ -390,6 +391,7 @@ function updateRemoteVideo (videoAttributesToUpdate, fromPod, finalCallback) { const options = { transaction: t } videoInstance.set('name', videoAttributesToUpdate.name) + videoInstance.set('category', videoAttributesToUpdate.category) videoInstance.set('description', videoAttributesToUpdate.description) videoInstance.set('infoHash', videoAttributesToUpdate.infoHash) videoInstance.set('duration', videoAttributesToUpdate.duration) diff --git a/server/controllers/api/videos.js b/server/controllers/api/videos.js index 9acdb8fd2..8c69ff4e5 100644 --- a/server/controllers/api/videos.js +++ b/server/controllers/api/videos.js @@ -45,6 +45,8 @@ const storage = multer.diskStorage({ const reqFiles = multer({ storage: storage }).fields([{ name: 'videofile', maxCount: 1 }]) +router.get('/categories', listVideoCategories) + router.get('/abuse', oAuth.authenticate, admin.ensureIsAdmin, @@ -110,6 +112,10 @@ module.exports = router // --------------------------------------------------------------------------- +function listVideoCategories (req, res, next) { + res.json(constants.VIDEO_CATEGORIES) +} + function rateVideoRetryWrapper (req, res, next) { const options = { arguments: [ req, res ], @@ -300,6 +306,7 @@ function addVideo (req, res, videoFile, finalCallback) { name: videoInfos.name, remoteId: null, extname: path.extname(videoFile.filename), + category: videoInfos.category, description: videoInfos.description, duration: videoFile.duration, authorId: author.id @@ -413,6 +420,7 @@ function updateVideo (req, res, finalCallback) { } if (videoInfosToUpdate.name) videoInstance.set('name', videoInfosToUpdate.name) + if (videoInfosToUpdate.category) videoInstance.set('category', videoInfosToUpdate.category) if (videoInfosToUpdate.description) videoInstance.set('description', videoInfosToUpdate.description) videoInstance.save(options).asCallback(function (err) { -- cgit v1.2.3