diff options
Diffstat (limited to 'server/lib/friends.js')
-rw-r--r-- | server/lib/friends.js | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/server/lib/friends.js b/server/lib/friends.js index d53ab4553..424a30801 100644 --- a/server/lib/friends.js +++ b/server/lib/friends.js | |||
@@ -12,15 +12,19 @@ const logger = require('../helpers/logger') | |||
12 | const peertubeCrypto = require('../helpers/peertube-crypto') | 12 | const peertubeCrypto = require('../helpers/peertube-crypto') |
13 | const requests = require('../helpers/requests') | 13 | const requests = require('../helpers/requests') |
14 | const RequestScheduler = require('./request-scheduler') | 14 | const RequestScheduler = require('./request-scheduler') |
15 | const RequestVideoQaduScheduler = require('./request-video-qadu-scheduler') | ||
15 | 16 | ||
16 | const ENDPOINT_ACTIONS = constants.REQUEST_ENDPOINT_ACTIONS[constants.REQUEST_ENDPOINTS.VIDEOS] | 17 | const ENDPOINT_ACTIONS = constants.REQUEST_ENDPOINT_ACTIONS[constants.REQUEST_ENDPOINTS.VIDEOS] |
18 | |||
17 | const requestScheduler = new RequestScheduler() | 19 | const requestScheduler = new RequestScheduler() |
20 | const requestSchedulerVideoQadu = new RequestVideoQaduScheduler() | ||
18 | 21 | ||
19 | const friends = { | 22 | const friends = { |
20 | activate, | 23 | activate, |
21 | addVideoToFriends, | 24 | addVideoToFriends, |
22 | updateVideoToFriends, | 25 | updateVideoToFriends, |
23 | reportAbuseVideoToFriend, | 26 | reportAbuseVideoToFriend, |
27 | quickAndDirtyUpdateVideoToFriends, | ||
24 | hasFriends, | 28 | hasFriends, |
25 | makeFriends, | 29 | makeFriends, |
26 | quitFriends, | 30 | quitFriends, |
@@ -30,6 +34,7 @@ const friends = { | |||
30 | 34 | ||
31 | function activate () { | 35 | function activate () { |
32 | requestScheduler.activate() | 36 | requestScheduler.activate() |
37 | requestSchedulerVideoQadu.activate() | ||
33 | } | 38 | } |
34 | 39 | ||
35 | function addVideoToFriends (videoData, transaction, callback) { | 40 | function addVideoToFriends (videoData, transaction, callback) { |
@@ -71,6 +76,15 @@ function reportAbuseVideoToFriend (reportData, video) { | |||
71 | createRequest(options) | 76 | createRequest(options) |
72 | } | 77 | } |
73 | 78 | ||
79 | function quickAndDirtyUpdateVideoToFriends (videoId, type, transaction, callback) { | ||
80 | const options = { | ||
81 | videoId, | ||
82 | type, | ||
83 | transaction | ||
84 | } | ||
85 | return createVideoQaduRequest(options, callback) | ||
86 | } | ||
87 | |||
74 | function hasFriends (callback) { | 88 | function hasFriends (callback) { |
75 | db.Pod.countAll(function (err, count) { | 89 | db.Pod.countAll(function (err, count) { |
76 | if (err) return callback(err) | 90 | if (err) return callback(err) |
@@ -110,7 +124,11 @@ function quitFriends (callback) { | |||
110 | 124 | ||
111 | waterfall([ | 125 | waterfall([ |
112 | function flushRequests (callbackAsync) { | 126 | function flushRequests (callbackAsync) { |
113 | requestScheduler.flush(callbackAsync) | 127 | requestScheduler.flush(err => callbackAsync(err)) |
128 | }, | ||
129 | |||
130 | function flushVideoQaduRequests (callbackAsync) { | ||
131 | requestSchedulerVideoQadu.flush(err => callbackAsync(err)) | ||
114 | }, | 132 | }, |
115 | 133 | ||
116 | function getPodsList (callbackAsync) { | 134 | function getPodsList (callbackAsync) { |
@@ -310,6 +328,12 @@ function createRequest (options, callback) { | |||
310 | }) | 328 | }) |
311 | } | 329 | } |
312 | 330 | ||
331 | function createVideoQaduRequest (options, callback) { | ||
332 | if (!callback) callback = function () {} | ||
333 | |||
334 | requestSchedulerVideoQadu.createRequest(options, callback) | ||
335 | } | ||
336 | |||
313 | function isMe (host) { | 337 | function isMe (host) { |
314 | return host === constants.CONFIG.WEBSERVER.HOST | 338 | return host === constants.CONFIG.WEBSERVER.HOST |
315 | } | 339 | } |