aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/friends.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-02-26 18:57:33 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-02-26 20:01:26 +0100
commite4c87ec26962e359d1c70b03ed188a3f19d6a25b (patch)
tree26fe20e6f600bc6f6f569dde2171b0a2346b135c /server/lib/friends.js
parent9e167724f7e933f41d9ea2e1c31772bf4c560a28 (diff)
downloadPeerTube-e4c87ec26962e359d1c70b03ed188a3f19d6a25b.tar.gz
PeerTube-e4c87ec26962e359d1c70b03ed188a3f19d6a25b.tar.zst
PeerTube-e4c87ec26962e359d1c70b03ed188a3f19d6a25b.zip
Server: implement video views
Diffstat (limited to 'server/lib/friends.js')
-rw-r--r--server/lib/friends.js22
1 files changed, 21 insertions, 1 deletions
diff --git a/server/lib/friends.js b/server/lib/friends.js
index 424a30801..203f0e52c 100644
--- a/server/lib/friends.js
+++ b/server/lib/friends.js
@@ -11,13 +11,16 @@ const db = require('../initializers/database')
11const logger = require('../helpers/logger') 11const logger = require('../helpers/logger')
12const peertubeCrypto = require('../helpers/peertube-crypto') 12const peertubeCrypto = require('../helpers/peertube-crypto')
13const requests = require('../helpers/requests') 13const requests = require('../helpers/requests')
14const utils = require('../helpers/utils')
14const RequestScheduler = require('./request-scheduler') 15const RequestScheduler = require('./request-scheduler')
15const RequestVideoQaduScheduler = require('./request-video-qadu-scheduler') 16const RequestVideoQaduScheduler = require('./request-video-qadu-scheduler')
17const RequestVideoEventScheduler = require('./request-video-event-scheduler')
16 18
17const ENDPOINT_ACTIONS = constants.REQUEST_ENDPOINT_ACTIONS[constants.REQUEST_ENDPOINTS.VIDEOS] 19const ENDPOINT_ACTIONS = constants.REQUEST_ENDPOINT_ACTIONS[constants.REQUEST_ENDPOINTS.VIDEOS]
18 20
19const requestScheduler = new RequestScheduler() 21const requestScheduler = new RequestScheduler()
20const requestSchedulerVideoQadu = new RequestVideoQaduScheduler() 22const requestSchedulerVideoQadu = new RequestVideoQaduScheduler()
23const requestSchedulerVideoEvent = new RequestVideoEventScheduler()
21 24
22const friends = { 25const friends = {
23 activate, 26 activate,
@@ -25,6 +28,7 @@ const friends = {
25 updateVideoToFriends, 28 updateVideoToFriends,
26 reportAbuseVideoToFriend, 29 reportAbuseVideoToFriend,
27 quickAndDirtyUpdateVideoToFriends, 30 quickAndDirtyUpdateVideoToFriends,
31 addEventToRemoteVideo,
28 hasFriends, 32 hasFriends,
29 makeFriends, 33 makeFriends,
30 quitFriends, 34 quitFriends,
@@ -35,6 +39,7 @@ const friends = {
35function activate () { 39function activate () {
36 requestScheduler.activate() 40 requestScheduler.activate()
37 requestSchedulerVideoQadu.activate() 41 requestSchedulerVideoQadu.activate()
42 requestSchedulerVideoEvent.activate()
38} 43}
39 44
40function addVideoToFriends (videoData, transaction, callback) { 45function addVideoToFriends (videoData, transaction, callback) {
@@ -85,6 +90,15 @@ function quickAndDirtyUpdateVideoToFriends (videoId, type, transaction, callback
85 return createVideoQaduRequest(options, callback) 90 return createVideoQaduRequest(options, callback)
86} 91}
87 92
93function addEventToRemoteVideo (videoId, type, transaction, callback) {
94 const options = {
95 videoId,
96 type,
97 transaction
98 }
99 createVideoEventRequest(options, callback)
100}
101
88function hasFriends (callback) { 102function hasFriends (callback) {
89 db.Pod.countAll(function (err, count) { 103 db.Pod.countAll(function (err, count) {
90 if (err) return callback(err) 104 if (err) return callback(err)
@@ -329,11 +343,17 @@ function createRequest (options, callback) {
329} 343}
330 344
331function createVideoQaduRequest (options, callback) { 345function createVideoQaduRequest (options, callback) {
332 if (!callback) callback = function () {} 346 if (!callback) callback = utils.createEmptyCallback()
333 347
334 requestSchedulerVideoQadu.createRequest(options, callback) 348 requestSchedulerVideoQadu.createRequest(options, callback)
335} 349}
336 350
351function createVideoEventRequest (options, callback) {
352 if (!callback) callback = utils.createEmptyCallback()
353
354 requestSchedulerVideoEvent.createRequest(options, callback)
355}
356
337function isMe (host) { 357function isMe (host) {
338 return host === constants.CONFIG.WEBSERVER.HOST 358 return host === constants.CONFIG.WEBSERVER.HOST
339} 359}