diff options
Diffstat (limited to 'server/controllers/api/users.js')
-rw-r--r-- | server/controllers/api/users.js | 27 |
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 | ||
19 | const router = express.Router() | 19 | const router = express.Router() |
20 | 20 | ||
21 | router.get('/me', oAuth.authenticate, getUserInformation) | 21 | router.get('/me', |
22 | oAuth.authenticate, | ||
23 | getUserInformation | ||
24 | ) | ||
25 | |||
26 | router.get('/me/videos/:videoId/rating', | ||
27 | oAuth.authenticate, | ||
28 | validatorsUsers.usersVideoRating, | ||
29 | getUserVideoRating | ||
30 | ) | ||
22 | 31 | ||
23 | router.get('/', | 32 | router.get('/', |
24 | validatorsPagination.pagination, | 33 | validatorsPagination.pagination, |
@@ -80,6 +89,22 @@ function getUserInformation (req, res, next) { | |||
80 | }) | 89 | }) |
81 | } | 90 | } |
82 | 91 | ||
92 | function 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 | |||
83 | function listUsers (req, res, next) { | 108 | function 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) |