aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/users.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-03-08 21:35:43 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-03-08 21:35:43 +0100
commitd38b82810638b9f664c9016fac2684454c273a77 (patch)
tree9465c367e5033675309efca4d66790c6fdd5230d /server/controllers/api/users.js
parent8f9064432122cba0f518a24ac4378357dadec589 (diff)
downloadPeerTube-d38b82810638b9f664c9016fac2684454c273a77.tar.gz
PeerTube-d38b82810638b9f664c9016fac2684454c273a77.tar.zst
PeerTube-d38b82810638b9f664c9016fac2684454c273a77.zip
Add like/dislike system for videos
Diffstat (limited to 'server/controllers/api/users.js')
-rw-r--r--server/controllers/api/users.js27
1 files changed, 26 insertions, 1 deletions
diff --git a/server/controllers/api/users.js b/server/controllers/api/users.js
index 324c99b4c..f854b3082 100644
--- a/server/controllers/api/users.js
+++ b/server/controllers/api/users.js
@@ -18,7 +18,16 @@ const validatorsUsers = middlewares.validators.users
18 18
19const router = express.Router() 19const router = express.Router()
20 20
21router.get('/me', oAuth.authenticate, getUserInformation) 21router.get('/me',
22 oAuth.authenticate,
23 getUserInformation
24)
25
26router.get('/me/videos/:videoId/rating',
27 oAuth.authenticate,
28 validatorsUsers.usersVideoRating,
29 getUserVideoRating
30)
22 31
23router.get('/', 32router.get('/',
24 validatorsPagination.pagination, 33 validatorsPagination.pagination,
@@ -80,6 +89,22 @@ function getUserInformation (req, res, next) {
80 }) 89 })
81} 90}
82 91
92function getUserVideoRating (req, res, next) {
93 const videoId = req.params.videoId
94 const userId = res.locals.oauth.token.User.id
95
96 db.UserVideoRate.load(userId, videoId, function (err, ratingObj) {
97 if (err) return next(err)
98
99 const rating = ratingObj ? ratingObj.type : 'none'
100
101 res.json({
102 videoId,
103 rating
104 })
105 })
106}
107
83function listUsers (req, res, next) { 108function listUsers (req, res, next) {
84 db.User.listForApi(req.query.start, req.query.count, req.query.sort, function (err, usersList, usersTotal) { 109 db.User.listForApi(req.query.start, req.query.count, req.query.sort, function (err, usersList, usersTotal) {
85 if (err) return next(err) 110 if (err) return next(err)