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.js21
1 files changed, 8 insertions, 13 deletions
diff --git a/server/lib/friends.js b/server/lib/friends.js
index d81a603ad..91cd69f86 100644
--- a/server/lib/friends.js
+++ b/server/lib/friends.js
@@ -3,6 +3,7 @@
3const async = require('async') 3const async = require('async')
4const config = require('config') 4const config = require('config')
5const fs = require('fs') 5const fs = require('fs')
6const mongoose = require('mongoose')
6const request = require('request') 7const request = require('request')
7 8
8const constants = require('../initializers/constants') 9const constants = require('../initializers/constants')
@@ -11,12 +12,11 @@ const peertubeCrypto = require('../helpers/peertubeCrypto')
11const Pods = require('../models/pods') 12const Pods = require('../models/pods')
12const requestsScheduler = require('../lib/requestsScheduler') 13const requestsScheduler = require('../lib/requestsScheduler')
13const requests = require('../helpers/requests') 14const requests = require('../helpers/requests')
14const videos = require('../lib/videos')
15const Videos = require('../models/videos')
16 15
17const http = config.get('webserver.https') ? 'https' : 'http' 16const http = config.get('webserver.https') ? 'https' : 'http'
18const host = config.get('webserver.host') 17const host = config.get('webserver.host')
19const port = config.get('webserver.port') 18const port = config.get('webserver.port')
19const Video = mongoose.model('Video')
20 20
21const pods = { 21const pods = {
22 addVideoToFriends: addVideoToFriends, 22 addVideoToFriends: addVideoToFriends,
@@ -117,18 +117,13 @@ function quitFriends (callback) {
117 function listRemoteVideos (callbackAsync) { 117 function listRemoteVideos (callbackAsync) {
118 logger.info('Broke friends, so sad :(') 118 logger.info('Broke friends, so sad :(')
119 119
120 Videos.listFromRemotes(callbackAsync) 120 Video.listRemotes(callbackAsync)
121 }, 121 },
122 122
123 function removeTheRemoteVideos (videosList, callbackAsync) { 123 function removeTheRemoteVideos (videosList, callbackAsync) {
124 videos.removeRemoteVideos(videosList, function (err) { 124 async.each(videosList, function (video, callbackEach) {
125 if (err) { 125 video.remove(callbackEach)
126 logger.error('Cannot remove remote videos.', { error: err }) 126 }, callbackAsync)
127 return callbackAsync(err)
128 }
129
130 return callbackAsync(null)
131 })
132 } 127 }
133 ], function (err) { 128 ], function (err) {
134 // Don't forget to re activate the scheduler, even if there was an error 129 // Don't forget to re activate the scheduler, even if there was an error
@@ -146,14 +141,14 @@ function removeVideoToFriends (video) {
146} 141}
147 142
148function sendOwnedVideosToPod (podId) { 143function sendOwnedVideosToPod (podId) {
149 Videos.listOwned(function (err, videosList) { 144 Video.listOwned(function (err, videosList) {
150 if (err) { 145 if (err) {
151 logger.error('Cannot get the list of videos we own.') 146 logger.error('Cannot get the list of videos we own.')
152 return 147 return
153 } 148 }
154 149
155 videosList.forEach(function (video) { 150 videosList.forEach(function (video) {
156 videos.convertVideoToRemote(video, function (err, remoteVideo) { 151 video.toRemoteJSON(function (err, remoteVideo) {
157 if (err) { 152 if (err) {
158 logger.error('Cannot convert video to remote.', { error: err }) 153 logger.error('Cannot convert video to remote.', { error: err })
159 // Don't break the process 154 // Don't break the process