aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video.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/models/video.js
parent8f9064432122cba0f518a24ac4378357dadec589 (diff)
downloadPeerTube-d38b82810638b9f664c9016fac2684454c273a77.tar.gz
PeerTube-d38b82810638b9f664c9016fac2684454c273a77.tar.zst
PeerTube-d38b82810638b9f664c9016fac2684454c273a77.zip
Add like/dislike system for videos
Diffstat (limited to 'server/models/video.js')
-rw-r--r--server/models/video.js31
1 files changed, 29 insertions, 2 deletions
diff --git a/server/models/video.js b/server/models/video.js
index fb46aca86..182555c85 100644
--- a/server/models/video.js
+++ b/server/models/video.js
@@ -89,6 +89,24 @@ module.exports = function (sequelize, DataTypes) {
89 min: 0, 89 min: 0,
90 isInt: true 90 isInt: true
91 } 91 }
92 },
93 likes: {
94 type: DataTypes.INTEGER,
95 allowNull: false,
96 defaultValue: 0,
97 validate: {
98 min: 0,
99 isInt: true
100 }
101 },
102 dislikes: {
103 type: DataTypes.INTEGER,
104 allowNull: false,
105 defaultValue: 0,
106 validate: {
107 min: 0,
108 isInt: true
109 }
92 } 110 }
93 }, 111 },
94 { 112 {
@@ -113,6 +131,9 @@ module.exports = function (sequelize, DataTypes) {
113 }, 131 },
114 { 132 {
115 fields: [ 'views' ] 133 fields: [ 'views' ]
134 },
135 {
136 fields: [ 'likes' ]
116 } 137 }
117 ], 138 ],
118 classMethods: { 139 classMethods: {
@@ -349,6 +370,8 @@ function toFormatedJSON () {
349 author: this.Author.name, 370 author: this.Author.name,
350 duration: this.duration, 371 duration: this.duration,
351 views: this.views, 372 views: this.views,
373 likes: this.likes,
374 dislikes: this.dislikes,
352 tags: map(this.Tags, 'name'), 375 tags: map(this.Tags, 'name'),
353 thumbnailPath: pathUtils.join(constants.STATIC_PATHS.THUMBNAILS, this.getThumbnailName()), 376 thumbnailPath: pathUtils.join(constants.STATIC_PATHS.THUMBNAILS, this.getThumbnailName()),
354 createdAt: this.createdAt, 377 createdAt: this.createdAt,
@@ -381,7 +404,9 @@ function toAddRemoteJSON (callback) {
381 createdAt: self.createdAt, 404 createdAt: self.createdAt,
382 updatedAt: self.updatedAt, 405 updatedAt: self.updatedAt,
383 extname: self.extname, 406 extname: self.extname,
384 views: self.views 407 views: self.views,
408 likes: self.likes,
409 dislikes: self.dislikes
385 } 410 }
386 411
387 return callback(null, remoteVideo) 412 return callback(null, remoteVideo)
@@ -400,7 +425,9 @@ function toUpdateRemoteJSON (callback) {
400 createdAt: this.createdAt, 425 createdAt: this.createdAt,
401 updatedAt: this.updatedAt, 426 updatedAt: this.updatedAt,
402 extname: this.extname, 427 extname: this.extname,
403 views: this.views 428 views: this.views,
429 likes: this.likes,
430 dislikes: this.dislikes
404 } 431 }
405 432
406 return json 433 return json