Server: add views attribute when sending videos to friends
authorChocobozzz <florian.bigard@gmail.com>
Sat, 4 Mar 2017 10:00:59 +0000 (11:00 +0100)
committerChocobozzz <florian.bigard@gmail.com>
Sat, 4 Mar 2017 10:00:59 +0000 (11:00 +0100)
server/controllers/api/videos.js
server/helpers/custom-validators/remote/videos.js
server/models/video.js

index dfd8699e6163a73cc4956c127cae45a3f59c38dc..5a67d1121fcb9c3f2f7df73ec548cb422b5e9f42 100644 (file)
@@ -155,7 +155,8 @@ function addVideo (req, res, videoFile, finalCallback) {
         extname: path.extname(videoFile.filename),
         description: videoInfos.description,
         duration: videoFile.duration,
-        authorId: author.id
+        authorId: author.id,
+        views: videoInfos.views
       }
 
       const video = db.Video.build(videoData)
index c1786014df5a5bae170cf0fb719594e1767e477d..ba2d0bb93bde1c1c3bc53e648dfdb01cd38f185a 100644 (file)
@@ -91,7 +91,8 @@ function isCommonVideoAttributesValid (video) {
          videosValidators.isVideoNameValid(video.name) &&
          videosValidators.isVideoTagsValid(video.tags) &&
          videosValidators.isVideoRemoteIdValid(video.remoteId) &&
-         videosValidators.isVideoExtnameValid(video.extname)
+         videosValidators.isVideoExtnameValid(video.extname) &&
+         videosValidators.isVideoViewsValid(video.views)
 }
 
 function isRequestTypeAddValid (value) {
index daa273845f5610de2b90f85df4a405a2cda2cb59..fb46aca869706a05a18e13a88d1700991ccf3761 100644 (file)
@@ -380,7 +380,8 @@ function toAddRemoteJSON (callback) {
       tags: map(self.Tags, 'name'),
       createdAt: self.createdAt,
       updatedAt: self.updatedAt,
-      extname: self.extname
+      extname: self.extname,
+      views: self.views
     }
 
     return callback(null, remoteVideo)
@@ -398,7 +399,8 @@ function toUpdateRemoteJSON (callback) {
     tags: map(this.Tags, 'name'),
     createdAt: this.createdAt,
     updatedAt: this.updatedAt,
-    extname: this.extname
+    extname: this.extname,
+    views: this.views
   }
 
   return json