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.js43
1 files changed, 37 insertions, 6 deletions
diff --git a/server/lib/friends.js b/server/lib/friends.js
index 7bd087d8c..23accfa45 100644
--- a/server/lib/friends.js
+++ b/server/lib/friends.js
@@ -3,6 +3,7 @@
3const each = require('async/each') 3const each = require('async/each')
4const eachLimit = require('async/eachLimit') 4const eachLimit = require('async/eachLimit')
5const eachSeries = require('async/eachSeries') 5const eachSeries = require('async/eachSeries')
6const series = require('async/series')
6const request = require('request') 7const request = require('request')
7const waterfall = require('async/waterfall') 8const waterfall = require('async/waterfall')
8 9
@@ -28,7 +29,9 @@ const friends = {
28 updateVideoToFriends, 29 updateVideoToFriends,
29 reportAbuseVideoToFriend, 30 reportAbuseVideoToFriend,
30 quickAndDirtyUpdateVideoToFriends, 31 quickAndDirtyUpdateVideoToFriends,
32 quickAndDirtyUpdatesVideoToFriends,
31 addEventToRemoteVideo, 33 addEventToRemoteVideo,
34 addEventsToRemoteVideo,
32 hasFriends, 35 hasFriends,
33 makeFriends, 36 makeFriends,
34 quitFriends, 37 quitFriends,
@@ -84,24 +87,52 @@ function reportAbuseVideoToFriend (reportData, video) {
84 createRequest(options) 87 createRequest(options)
85} 88}
86 89
87function quickAndDirtyUpdateVideoToFriends (videoId, type, transaction, callback) { 90function quickAndDirtyUpdateVideoToFriends (qaduParams, transaction, callback) {
88 const options = { 91 const options = {
89 videoId, 92 videoId: qaduParams.videoId,
90 type, 93 type: qaduParams.type,
91 transaction 94 transaction
92 } 95 }
93 return createVideoQaduRequest(options, callback) 96 return createVideoQaduRequest(options, callback)
94} 97}
95 98
96function addEventToRemoteVideo (videoId, type, transaction, callback) { 99function quickAndDirtyUpdatesVideoToFriends (qadusParams, transaction, finalCallback) {
100 const tasks = []
101
102 qadusParams.forEach(function (qaduParams) {
103 const fun = function (callback) {
104 quickAndDirtyUpdateVideoToFriends(qaduParams, transaction, callback)
105 }
106
107 tasks.push(fun)
108 })
109
110 series(tasks, finalCallback)
111}
112
113function addEventToRemoteVideo (eventParams, transaction, callback) {
97 const options = { 114 const options = {
98 videoId, 115 videoId: eventParams.videoId,
99 type, 116 type: eventParams.type,
100 transaction 117 transaction
101 } 118 }
102 createVideoEventRequest(options, callback) 119 createVideoEventRequest(options, callback)
103} 120}
104 121
122function addEventsToRemoteVideo (eventsParams, transaction, finalCallback) {
123 const tasks = []
124
125 eventsParams.forEach(function (eventParams) {
126 const fun = function (callback) {
127 addEventToRemoteVideo(eventParams, transaction, callback)
128 }
129
130 tasks.push(fun)
131 })
132
133 series(tasks, finalCallback)
134}
135
105function hasFriends (callback) { 136function hasFriends (callback) {
106 db.Pod.countAll(function (err, count) { 137 db.Pod.countAll(function (err, count) {
107 if (err) return callback(err) 138 if (err) return callback(err)