aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/users.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-12-29 11:17:11 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-12-29 11:17:11 +0100
commit98ac898a03ed7bbb4edec74fe823b3f2d6d4904a (patch)
treed96e2b5fe8db9b4f1f1628067910495ec5679e3e /server/controllers/api/users.js
parent4712081f2a5f48749cf125d729e78b926ab28d6d (diff)
downloadPeerTube-98ac898a03ed7bbb4edec74fe823b3f2d6d4904a.tar.gz
PeerTube-98ac898a03ed7bbb4edec74fe823b3f2d6d4904a.tar.zst
PeerTube-98ac898a03ed7bbb4edec74fe823b3f2d6d4904a.zip
Server: use video hook to send information to other pods when a video is
deleted
Diffstat (limited to 'server/controllers/api/users.js')
-rw-r--r--server/controllers/api/users.js32
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
91function removeUser (req, res, next) { 91function 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) {