diff options
Diffstat (limited to 'server/controllers/api/users.js')
-rw-r--r-- | server/controllers/api/users.js | 32 |
1 files changed, 2 insertions, 30 deletions
diff --git a/server/controllers/api/users.js b/server/controllers/api/users.js index 890028b36..e4423680c 100644 --- a/server/controllers/api/users.js +++ b/server/controllers/api/users.js | |||
@@ -90,39 +90,11 @@ function listUsers (req, res, next) { | |||
90 | 90 | ||
91 | function removeUser (req, res, next) { | 91 | function removeUser (req, res, next) { |
92 | waterfall([ | 92 | waterfall([ |
93 | function getUser (callback) { | 93 | function loadUser (callback) { |
94 | db.User.loadById(req.params.id, callback) | 94 | db.User.loadById(req.params.id, callback) |
95 | }, | 95 | }, |
96 | 96 | ||
97 | // TODO: use foreignkey? | 97 | function deleteUser (user, callback) { |
98 | function getVideos (user, callback) { | ||
99 | db.Video.listOwnedByAuthor(user.username, function (err, videos) { | ||
100 | return callback(err, user, videos) | ||
101 | }) | ||
102 | }, | ||
103 | |||
104 | function removeVideosFromDB (user, videos, callback) { | ||
105 | each(videos, function (video, callbackEach) { | ||
106 | video.destroy().asCallback(callbackEach) | ||
107 | }, function (err) { | ||
108 | return callback(err, user, videos) | ||
109 | }) | ||
110 | }, | ||
111 | |||
112 | function sendInformationToFriends (user, videos, callback) { | ||
113 | videos.forEach(function (video) { | ||
114 | const params = { | ||
115 | name: video.name, | ||
116 | remoteId: video.id | ||
117 | } | ||
118 | |||
119 | friends.removeVideoToFriends(params) | ||
120 | }) | ||
121 | |||
122 | return callback(null, user) | ||
123 | }, | ||
124 | |||
125 | function removeUserFromDB (user, callback) { | ||
126 | user.destroy().asCallback(callback) | 98 | user.destroy().asCallback(callback) |
127 | } | 99 | } |
128 | ], function andFinally (err) { | 100 | ], function andFinally (err) { |