diff options
Diffstat (limited to 'server/controllers/api/v1/videos.js')
-rw-r--r-- | server/controllers/api/v1/videos.js | 11 |
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') | |||
8 | const logger = require('../../../helpers/logger') | 8 | const logger = require('../../../helpers/logger') |
9 | const friends = require('../../../lib/friends') | 9 | const friends = require('../../../lib/friends') |
10 | const middleware = require('../../../middlewares') | 10 | const middleware = require('../../../middlewares') |
11 | const oAuth2 = require('../../../middlewares/oauth2') | ||
11 | const cacheMiddleware = middleware.cache | 12 | const cacheMiddleware = middleware.cache |
12 | const reqValidator = middleware.reqValidators.videos | 13 | const reqValidator = middleware.reqValidators.videos |
13 | const Videos = require('../../../models/videos') // model | 14 | const Videos = require('../../../models/videos') // model |
@@ -38,9 +39,9 @@ const storage = multer.diskStorage({ | |||
38 | const reqFiles = multer({ storage: storage }).fields([{ name: 'videofile', maxCount: 1 }]) | 39 | const reqFiles = multer({ storage: storage }).fields([{ name: 'videofile', maxCount: 1 }]) |
39 | 40 | ||
40 | router.get('/', cacheMiddleware.cache(false), listVideos) | 41 | router.get('/', cacheMiddleware.cache(false), listVideos) |
41 | router.post('/', reqFiles, reqValidator.videosAdd, cacheMiddleware.cache(false), addVideo) | 42 | router.post('/', oAuth2.authenticate, reqFiles, reqValidator.videosAdd, cacheMiddleware.cache(false), addVideo) |
42 | router.get('/:id', reqValidator.videosGet, cacheMiddleware.cache(false), getVideos) | 43 | router.get('/:id', reqValidator.videosGet, cacheMiddleware.cache(false), getVideos) |
43 | router.delete('/:id', reqValidator.videosRemove, cacheMiddleware.cache(false), removeVideo) | 44 | router.delete('/:id', oAuth2.authenticate, reqValidator.videosRemove, cacheMiddleware.cache(false), removeVideo) |
44 | router.get('/search/:name', reqValidator.videosSearch, cacheMiddleware.cache(false), searchVideos) | 45 | router.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 |