diff options
Diffstat (limited to 'server/controllers/api/videos.js')
-rw-r--r-- | server/controllers/api/videos.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/server/controllers/api/videos.js b/server/controllers/api/videos.js index c936105e7..9f4bbb7b7 100644 --- a/server/controllers/api/videos.js +++ b/server/controllers/api/videos.js | |||
@@ -320,6 +320,22 @@ function updateVideo (req, res, finalCallback) { | |||
320 | 320 | ||
321 | function getVideo (req, res, next) { | 321 | function getVideo (req, res, next) { |
322 | const videoInstance = res.locals.video | 322 | const videoInstance = res.locals.video |
323 | |||
324 | if (videoInstance.isOwned()) { | ||
325 | // The increment is done directly in the database, not using the instance value | ||
326 | videoInstance.increment('views').asCallback(function (err) { | ||
327 | if (err) { | ||
328 | logger.error('Cannot add view to video %d.', videoInstance.id) | ||
329 | return | ||
330 | } | ||
331 | |||
332 | // FIXME: make a real view system | ||
333 | // For example, only add a view when a user watch a video during 30s etc | ||
334 | friends.quickAndDirtyUpdateVideoToFriends(videoInstance.id, constants.REQUEST_VIDEO_QADU_TYPES.VIEWS) | ||
335 | }) | ||
336 | } | ||
337 | |||
338 | // Do not wait the view system | ||
323 | res.json(videoInstance.toFormatedJSON()) | 339 | res.json(videoInstance.toFormatedJSON()) |
324 | } | 340 | } |
325 | 341 | ||