mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 10:19:35 +02:00
Add like/dislike system for videos
This commit is contained in:
parent
8f90644321
commit
d38b828106
31 changed files with 907 additions and 47 deletions
|
@ -18,7 +18,16 @@ const validatorsUsers = middlewares.validators.users
|
|||
|
||||
const router = express.Router()
|
||||
|
||||
router.get('/me', oAuth.authenticate, getUserInformation)
|
||||
router.get('/me',
|
||||
oAuth.authenticate,
|
||||
getUserInformation
|
||||
)
|
||||
|
||||
router.get('/me/videos/:videoId/rating',
|
||||
oAuth.authenticate,
|
||||
validatorsUsers.usersVideoRating,
|
||||
getUserVideoRating
|
||||
)
|
||||
|
||||
router.get('/',
|
||||
validatorsPagination.pagination,
|
||||
|
@ -80,6 +89,22 @@ function getUserInformation (req, res, next) {
|
|||
})
|
||||
}
|
||||
|
||||
function getUserVideoRating (req, res, next) {
|
||||
const videoId = req.params.videoId
|
||||
const userId = res.locals.oauth.token.User.id
|
||||
|
||||
db.UserVideoRate.load(userId, videoId, function (err, ratingObj) {
|
||||
if (err) return next(err)
|
||||
|
||||
const rating = ratingObj ? ratingObj.type : 'none'
|
||||
|
||||
res.json({
|
||||
videoId,
|
||||
rating
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function listUsers (req, res, next) {
|
||||
db.User.listForApi(req.query.start, req.query.count, req.query.sort, function (err, usersList, usersTotal) {
|
||||
if (err) return next(err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue