aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
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/helpers
parent8f9064432122cba0f518a24ac4378357dadec589 (diff)
downloadPeerTube-d38b82810638b9f664c9016fac2684454c273a77.tar.gz
PeerTube-d38b82810638b9f664c9016fac2684454c273a77.tar.zst
PeerTube-d38b82810638b9f664c9016fac2684454c273a77.zip
Add like/dislike system for videos
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/custom-validators/remote/videos.js4
-rw-r--r--server/helpers/custom-validators/videos.js6
2 files changed, 9 insertions, 1 deletions
diff --git a/server/helpers/custom-validators/remote/videos.js b/server/helpers/custom-validators/remote/videos.js
index ba2d0bb93..e1636e0e6 100644
--- a/server/helpers/custom-validators/remote/videos.js
+++ b/server/helpers/custom-validators/remote/videos.js
@@ -92,7 +92,9 @@ function isCommonVideoAttributesValid (video) {
92 videosValidators.isVideoTagsValid(video.tags) && 92 videosValidators.isVideoTagsValid(video.tags) &&
93 videosValidators.isVideoRemoteIdValid(video.remoteId) && 93 videosValidators.isVideoRemoteIdValid(video.remoteId) &&
94 videosValidators.isVideoExtnameValid(video.extname) && 94 videosValidators.isVideoExtnameValid(video.extname) &&
95 videosValidators.isVideoViewsValid(video.views) 95 videosValidators.isVideoViewsValid(video.views) &&
96 videosValidators.isVideoLikesValid(video.likes) &&
97 videosValidators.isVideoDislikesValid(video.dislikes)
96} 98}
97 99
98function isRequestTypeAddValid (value) { 100function isRequestTypeAddValid (value) {
diff --git a/server/helpers/custom-validators/videos.js b/server/helpers/custom-validators/videos.js
index c5a1f3cb5..648c7540b 100644
--- a/server/helpers/custom-validators/videos.js
+++ b/server/helpers/custom-validators/videos.js
@@ -1,6 +1,7 @@
1'use strict' 1'use strict'
2 2
3const validator = require('express-validator').validator 3const validator = require('express-validator').validator
4const values = require('lodash/values')
4 5
5const constants = require('../../initializers/constants') 6const constants = require('../../initializers/constants')
6const usersValidators = require('./users') 7const usersValidators = require('./users')
@@ -26,6 +27,7 @@ const videosValidators = {
26 isVideoFile, 27 isVideoFile,
27 isVideoViewsValid, 28 isVideoViewsValid,
28 isVideoLikesValid, 29 isVideoLikesValid,
30 isVideoRatingTypeValid,
29 isVideoDislikesValid, 31 isVideoDislikesValid,
30 isVideoEventCountValid 32 isVideoEventCountValid
31} 33}
@@ -103,6 +105,10 @@ function isVideoEventCountValid (value) {
103 return validator.isInt(value + '', VIDEO_EVENTS_CONSTRAINTS_FIELDS.COUNT) 105 return validator.isInt(value + '', VIDEO_EVENTS_CONSTRAINTS_FIELDS.COUNT)
104} 106}
105 107
108function isVideoRatingTypeValid (value) {
109 return values(constants.VIDEO_RATE_TYPES).indexOf(value) !== -1
110}
111
106function isVideoFile (value, files) { 112function isVideoFile (value, files) {
107 // Should have files 113 // Should have files
108 if (!files) return false 114 if (!files) return false