aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/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/middlewares/validators/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/middlewares/validators/users.js')
-rw-r--r--server/middlewares/validators/users.js22
1 files changed, 21 insertions, 1 deletions
diff --git a/server/middlewares/validators/users.js b/server/middlewares/validators/users.js
index 3089370ff..ce83fc074 100644
--- a/server/middlewares/validators/users.js
+++ b/server/middlewares/validators/users.js
@@ -7,7 +7,8 @@ const logger = require('../../helpers/logger')
7const validatorsUsers = { 7const validatorsUsers = {
8 usersAdd, 8 usersAdd,
9 usersRemove, 9 usersRemove,
10 usersUpdate 10 usersUpdate,
11 usersVideoRating
11} 12}
12 13
13function usersAdd (req, res, next) { 14function usersAdd (req, res, next) {
@@ -62,6 +63,25 @@ function usersUpdate (req, res, next) {
62 checkErrors(req, res, next) 63 checkErrors(req, res, next)
63} 64}
64 65
66function usersVideoRating (req, res, next) {
67 req.checkParams('videoId', 'Should have a valid video id').notEmpty().isUUID(4)
68
69 logger.debug('Checking usersVideoRating parameters', { parameters: req.params })
70
71 checkErrors(req, res, function () {
72 db.Video.load(req.params.videoId, function (err, video) {
73 if (err) {
74 logger.error('Error in user request validator.', { error: err })
75 return res.sendStatus(500)
76 }
77
78 if (!video) return res.status(404).send('Video not found')
79
80 next()
81 })
82 })
83}
84
65// --------------------------------------------------------------------------- 85// ---------------------------------------------------------------------------
66 86
67module.exports = validatorsUsers 87module.exports = validatorsUsers