aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/friends.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/friends.js')
-rw-r--r--server/lib/friends.js26
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')
12const peertubeCrypto = require('../helpers/peertube-crypto') 12const peertubeCrypto = require('../helpers/peertube-crypto')
13const requests = require('../helpers/requests') 13const requests = require('../helpers/requests')
14const RequestScheduler = require('./request-scheduler') 14const RequestScheduler = require('./request-scheduler')
15const RequestVideoQaduScheduler = require('./request-video-qadu-scheduler')
15 16
16const ENDPOINT_ACTIONS = constants.REQUEST_ENDPOINT_ACTIONS[constants.REQUEST_ENDPOINTS.VIDEOS] 17const ENDPOINT_ACTIONS = constants.REQUEST_ENDPOINT_ACTIONS[constants.REQUEST_ENDPOINTS.VIDEOS]
18
17const requestScheduler = new RequestScheduler() 19const requestScheduler = new RequestScheduler()
20const requestSchedulerVideoQadu = new RequestVideoQaduScheduler()
18 21
19const friends = { 22const 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
31function activate () { 35function activate () {
32 requestScheduler.activate() 36 requestScheduler.activate()
37 requestSchedulerVideoQadu.activate()
33} 38}
34 39
35function addVideoToFriends (videoData, transaction, callback) { 40function addVideoToFriends (videoData, transaction, callback) {
@@ -71,6 +76,15 @@ function reportAbuseVideoToFriend (reportData, video) {
71 createRequest(options) 76 createRequest(options)
72} 77}
73 78
79function quickAndDirtyUpdateVideoToFriends (videoId, type, transaction, callback) {
80 const options = {
81 videoId,
82 type,
83 transaction
84 }
85 return createVideoQaduRequest(options, callback)
86}
87
74function hasFriends (callback) { 88function 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
331function createVideoQaduRequest (options, callback) {
332 if (!callback) callback = function () {}
333
334 requestSchedulerVideoQadu.createRequest(options, callback)
335}
336
313function isMe (host) { 337function isMe (host) {
314 return host === constants.CONFIG.WEBSERVER.HOST 338 return host === constants.CONFIG.WEBSERVER.HOST
315} 339}