aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/v1/videos.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/v1/videos.js')
-rw-r--r--server/controllers/api/v1/videos.js11
1 files changed, 7 insertions, 4 deletions
diff --git a/server/controllers/api/v1/videos.js b/server/controllers/api/v1/videos.js
index 97d3e6b5a..d25ca95f7 100644
--- a/server/controllers/api/v1/videos.js
+++ b/server/controllers/api/v1/videos.js
@@ -8,6 +8,7 @@ const multer = require('multer')
8const logger = require('../../../helpers/logger') 8const logger = require('../../../helpers/logger')
9const friends = require('../../../lib/friends') 9const friends = require('../../../lib/friends')
10const middleware = require('../../../middlewares') 10const middleware = require('../../../middlewares')
11const oAuth2 = require('../../../middlewares/oauth2')
11const cacheMiddleware = middleware.cache 12const cacheMiddleware = middleware.cache
12const reqValidator = middleware.reqValidators.videos 13const reqValidator = middleware.reqValidators.videos
13const Videos = require('../../../models/videos') // model 14const Videos = require('../../../models/videos') // model
@@ -38,9 +39,9 @@ const storage = multer.diskStorage({
38const reqFiles = multer({ storage: storage }).fields([{ name: 'videofile', maxCount: 1 }]) 39const reqFiles = multer({ storage: storage }).fields([{ name: 'videofile', maxCount: 1 }])
39 40
40router.get('/', cacheMiddleware.cache(false), listVideos) 41router.get('/', cacheMiddleware.cache(false), listVideos)
41router.post('/', reqFiles, reqValidator.videosAdd, cacheMiddleware.cache(false), addVideo) 42router.post('/', oAuth2.authenticate, reqFiles, reqValidator.videosAdd, cacheMiddleware.cache(false), addVideo)
42router.get('/:id', reqValidator.videosGet, cacheMiddleware.cache(false), getVideos) 43router.get('/:id', reqValidator.videosGet, cacheMiddleware.cache(false), getVideos)
43router.delete('/:id', reqValidator.videosRemove, cacheMiddleware.cache(false), removeVideo) 44router.delete('/:id', oAuth2.authenticate, reqValidator.videosRemove, cacheMiddleware.cache(false), removeVideo)
44router.get('/search/:name', reqValidator.videosSearch, cacheMiddleware.cache(false), searchVideos) 45router.get('/search/:name', reqValidator.videosSearch, cacheMiddleware.cache(false), searchVideos)
45 46
46// --------------------------------------------------------------------------- 47// ---------------------------------------------------------------------------
@@ -63,7 +64,8 @@ function addVideo (req, res, next) {
63 name: video_infos.name, 64 name: video_infos.name,
64 namePath: video_file.filename, 65 namePath: video_file.filename,
65 description: video_infos.description, 66 description: video_infos.description,
66 magnetUri: torrent.magnetURI 67 magnetUri: torrent.magnetURI,
68 author: res.locals.oauth.token.user.username
67 } 69 }
68 70
69 Videos.add(video_data, function (err) { 71 Videos.add(video_data, function (err) {
@@ -141,7 +143,8 @@ function getFormatedVideo (video_obj) {
141 description: video_obj.description, 143 description: video_obj.description,
142 podUrl: video_obj.podUrl, 144 podUrl: video_obj.podUrl,
143 isLocal: videos.getVideoState(video_obj).owned, 145 isLocal: videos.getVideoState(video_obj).owned,
144 magnetUri: video_obj.magnetUri 146 magnetUri: video_obj.magnetUri,
147 author: video_obj.author
145 } 148 }
146 149
147 return formated_video 150 return formated_video