diff options
Diffstat (limited to 'server/lib/friends.js')
-rw-r--r-- | server/lib/friends.js | 21 |
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 @@ | |||
3 | const async = require('async') | 3 | const async = require('async') |
4 | const config = require('config') | 4 | const config = require('config') |
5 | const fs = require('fs') | 5 | const fs = require('fs') |
6 | const mongoose = require('mongoose') | ||
6 | const request = require('request') | 7 | const request = require('request') |
7 | 8 | ||
8 | const constants = require('../initializers/constants') | 9 | const constants = require('../initializers/constants') |
@@ -11,12 +12,11 @@ const peertubeCrypto = require('../helpers/peertubeCrypto') | |||
11 | const Pods = require('../models/pods') | 12 | const Pods = require('../models/pods') |
12 | const requestsScheduler = require('../lib/requestsScheduler') | 13 | const requestsScheduler = require('../lib/requestsScheduler') |
13 | const requests = require('../helpers/requests') | 14 | const requests = require('../helpers/requests') |
14 | const videos = require('../lib/videos') | ||
15 | const Videos = require('../models/videos') | ||
16 | 15 | ||
17 | const http = config.get('webserver.https') ? 'https' : 'http' | 16 | const http = config.get('webserver.https') ? 'https' : 'http' |
18 | const host = config.get('webserver.host') | 17 | const host = config.get('webserver.host') |
19 | const port = config.get('webserver.port') | 18 | const port = config.get('webserver.port') |
19 | const Video = mongoose.model('Video') | ||
20 | 20 | ||
21 | const pods = { | 21 | const 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 | ||
148 | function sendOwnedVideosToPod (podId) { | 143 | function 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 |