diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-03-08 21:35:43 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-03-08 21:35:43 +0100 |
commit | d38b82810638b9f664c9016fac2684454c273a77 (patch) | |
tree | 9465c367e5033675309efca4d66790c6fdd5230d /server/helpers/custom-validators | |
parent | 8f9064432122cba0f518a24ac4378357dadec589 (diff) | |
download | PeerTube-d38b82810638b9f664c9016fac2684454c273a77.tar.gz PeerTube-d38b82810638b9f664c9016fac2684454c273a77.tar.zst PeerTube-d38b82810638b9f664c9016fac2684454c273a77.zip |
Add like/dislike system for videos
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r-- | server/helpers/custom-validators/remote/videos.js | 4 | ||||
-rw-r--r-- | server/helpers/custom-validators/videos.js | 6 |
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 | ||
98 | function isRequestTypeAddValid (value) { | 100 | function 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 | ||
3 | const validator = require('express-validator').validator | 3 | const validator = require('express-validator').validator |
4 | const values = require('lodash/values') | ||
4 | 5 | ||
5 | const constants = require('../../initializers/constants') | 6 | const constants = require('../../initializers/constants') |
6 | const usersValidators = require('./users') | 7 | const 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 | ||
108 | function isVideoRatingTypeValid (value) { | ||
109 | return values(constants.VIDEO_RATE_TYPES).indexOf(value) !== -1 | ||
110 | } | ||
111 | |||
106 | function isVideoFile (value, files) { | 112 | function isVideoFile (value, files) { |
107 | // Should have files | 113 | // Should have files |
108 | if (!files) return false | 114 | if (!files) return false |