1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 10:19:35 +02:00

Server: use video hook to send information to other pods when a video is

deleted
This commit is contained in:
Chocobozzz 2016-12-29 11:17:11 +01:00
parent 4712081f2a
commit 98ac898a03
4 changed files with 23 additions and 49 deletions

View file

@ -90,39 +90,11 @@ function listUsers (req, res, next) {
function removeUser (req, res, next) {
waterfall([
function getUser (callback) {
function loadUser (callback) {
db.User.loadById(req.params.id, callback)
},
// TODO: use foreignkey?
function getVideos (user, callback) {
db.Video.listOwnedByAuthor(user.username, function (err, videos) {
return callback(err, user, videos)
})
},
function removeVideosFromDB (user, videos, callback) {
each(videos, function (video, callbackEach) {
video.destroy().asCallback(callbackEach)
}, function (err) {
return callback(err, user, videos)
})
},
function sendInformationToFriends (user, videos, callback) {
videos.forEach(function (video) {
const params = {
name: video.name,
remoteId: video.id
}
friends.removeVideoToFriends(params)
})
return callback(null, user)
},
function removeUserFromDB (user, callback) {
function deleteUser (user, callback) {
user.destroy().asCallback(callback)
}
], function andFinally (err) {