addRemoteVideo(videoData, callbackEach)
} else if (request.type === 'remove') {
removeRemoteVideo(videoData, fromUrl, callbackEach)
+ } else {
+ logger.error('Unkown remote request type %s.', request.type)
}
}, function (err) {
if (err) logger.error('Error managing remote videos.', { error: err })
}
function addRemoteVideo (videoToCreateData, callback) {
+ logger.debug('Adding remote video %s.', videoToCreateData.magnetUri)
+
// Mongoose pre hook will automatically create the thumbnail on disk
videoToCreateData.thumbnail = videoToCreateData.thumbnailBase64
return callback(err)
}
+ if (videosList.length === 0) {
+ logger.error('No remote video was found for this pod.', { magnetUri: videoToRemoveData.magnetUri, podUrl: fromUrl })
+ }
+
async.each(videosList, function (video, callbackEach) {
+ logger.debug('Removing remote video %s.', video.magnetUri)
+
video.remove(callbackEach)
}, callback)
})
}
function list (callback) {
- this.find({ }, { _id: 1, request: 1, to: 1 }, callback)
+ this.find({ }, { _id: 1, request: 1, to: 1 }).sort({ _id: 1 }).exec(callback)
}
function removeAll (callback) {
const testUtils = {
dateIsValid: dateIsValid,
flushTests: flushTests,
+ getAllVideosListBy: getAllVideosListBy,
getFriendsList: getFriendsList,
getVideo: getVideo,
getVideosList: getVideosList,
exec('npm run clean:server:test', callback)
}
+function getAllVideosListBy (url, end) {
+ const path = '/api/v1/videos'
+
+ request(url)
+ .get(path)
+ .query({ sort: 'createdDate' })
+ .query({ start: 0 })
+ .query({ count: 10000 })
+ .set('Accept', 'application/json')
+ .expect(200)
+ .expect('Content-Type', /json/)
+ .end(end)
+}
+
function getFriendsList (url, end) {
const path = '/api/v1/pods/'