db.Pod.loadByHost(host, callback)
},
- function removePod (pod, callback) {
+ function deletePod (pod, callback) {
pod.destroy().asCallback(callback)
}
], function (err) {
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) {
const videoId = req.params.id
waterfall([
- function getVideo (callback) {
- db.Video.load(videoId, callback)
- },
-
- function removeFromDB (video, callback) {
- video.destroy().asCallback(function (err) {
- if (err) return callback(err)
-
- return callback(null, video)
+ function loadVideo (callback) {
+ db.Video.load(videoId, function (err, video) {
+ return callback(err, video)
})
},
- function sendInformationToFriends (video, callback) {
- const params = {
- name: video.name,
- remoteId: video.id
- }
-
- friends.removeVideoToFriends(params)
-
- return callback(null)
+ function deleteVideo (video, callback) {
+ // Informations to other pods will be sent by the afterDestroy video hook
+ video.destroy().asCallback(callback)
}
], function andFinally (err) {
if (err) {
const constants = require('../initializers/constants')
const logger = require('../helpers/logger')
+const friends = require('../lib/friends')
const modelUtils = require('./utils')
const customVideosValidators = require('../helpers/custom-validators').videos
function (callback) {
removeFile(video, callback)
},
+
function (callback) {
removeTorrent(video, callback)
},
+
function (callback) {
removePreview(video, callback)
+ },
+
+ function (callback) {
+ const params = {
+ name: video.name,
+ remoteId: video.id
+ }
+
+ friends.removeVideoToFriends(params)
+
+ return callback()
}
)
}