From e3d156b341ec1f834d119bfc1b15df6ef9fda737 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 4 Mar 2017 11:00:59 +0100 Subject: [PATCH] Server: add views attribute when sending videos to friends --- server/controllers/api/videos.js | 3 ++- server/helpers/custom-validators/remote/videos.js | 3 ++- server/models/video.js | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/server/controllers/api/videos.js b/server/controllers/api/videos.js index dfd8699e6..5a67d1121 100644 --- a/server/controllers/api/videos.js +++ b/server/controllers/api/videos.js @@ -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) diff --git a/server/helpers/custom-validators/remote/videos.js b/server/helpers/custom-validators/remote/videos.js index c1786014d..ba2d0bb93 100644 --- a/server/helpers/custom-validators/remote/videos.js +++ b/server/helpers/custom-validators/remote/videos.js @@ -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) { diff --git a/server/models/video.js b/server/models/video.js index daa273845..fb46aca86 100644 --- a/server/models/video.js +++ b/server/models/video.js @@ -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 -- 2.41.0