diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-05-22 09:15:00 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-05-22 09:15:00 +0200 |
commit | 46246b5f194caafba4e3a72e9365acd8b35785de (patch) | |
tree | 943689b44a9e447872cd7dd1c2a70dcc9256b990 /server/controllers | |
parent | 68ce3ae021c9bc11b155044df6d23ba60e91eee4 (diff) | |
download | PeerTube-46246b5f194caafba4e3a72e9365acd8b35785de.tar.gz PeerTube-46246b5f194caafba4e3a72e9365acd8b35785de.tar.zst PeerTube-46246b5f194caafba4e3a72e9365acd8b35785de.zip |
Extends the search feature by customizing the search field (name,
podUrl...)
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/api/v1/videos.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/server/controllers/api/v1/videos.js b/server/controllers/api/v1/videos.js index f7aeea453..7f59dd232 100644 --- a/server/controllers/api/v1/videos.js +++ b/server/controllers/api/v1/videos.js | |||
@@ -17,6 +17,7 @@ const reqValidator = middlewares.reqValidators | |||
17 | const reqValidatorPagination = reqValidator.pagination | 17 | const reqValidatorPagination = reqValidator.pagination |
18 | const reqValidatorSort = reqValidator.sort | 18 | const reqValidatorSort = reqValidator.sort |
19 | const reqValidatorVideos = reqValidator.videos | 19 | const reqValidatorVideos = reqValidator.videos |
20 | const search = middlewares.search | ||
20 | const sort = middlewares.sort | 21 | const sort = middlewares.sort |
21 | const utils = require('../../../helpers/utils') | 22 | const utils = require('../../../helpers/utils') |
22 | const Videos = require('../../../models/videos') // model | 23 | const Videos = require('../../../models/videos') // model |
@@ -69,12 +70,13 @@ router.delete('/:id', | |||
69 | reqValidatorVideos.videosRemove, | 70 | reqValidatorVideos.videosRemove, |
70 | removeVideo | 71 | removeVideo |
71 | ) | 72 | ) |
72 | router.get('/search/:name', | 73 | router.get('/search/:value', |
73 | reqValidatorVideos.videosSearch, | 74 | reqValidatorVideos.videosSearch, |
74 | reqValidatorPagination.pagination, | 75 | reqValidatorPagination.pagination, |
75 | reqValidatorSort.videosSort, | 76 | reqValidatorSort.videosSort, |
76 | sort.setVideosSort, | 77 | sort.setVideosSort, |
77 | pagination.setPagination, | 78 | pagination.setPagination, |
79 | search.setVideosSearch, | ||
78 | searchVideos | 80 | searchVideos |
79 | ) | 81 | ) |
80 | 82 | ||
@@ -237,7 +239,8 @@ function removeVideo (req, res, next) { | |||
237 | } | 239 | } |
238 | 240 | ||
239 | function searchVideos (req, res, next) { | 241 | function searchVideos (req, res, next) { |
240 | Videos.search(req.params.name, req.query.start, req.query.count, req.query.sort, function (err, videosList, totalVideos) { | 242 | Videos.search(req.params.value, req.query.field, req.query.start, req.query.count, req.query.sort, |
243 | function (err, videosList, totalVideos) { | ||
241 | if (err) return next(err) | 244 | if (err) return next(err) |
242 | 245 | ||
243 | res.json(getFormatedVideos(videosList, totalVideos)) | 246 | res.json(getFormatedVideos(videosList, totalVideos)) |