on user delete leaveAllGroups and remove from pending invited sets as well

v1.18.x
barisusakli 10 years ago
parent 19b50c8888
commit 6fd772756c

@ -163,11 +163,14 @@ module.exports = function(Groups) {
}; };
Groups.leaveAllGroups = function(uid, callback) { Groups.leaveAllGroups = function(uid, callback) {
db.getSortedSetRange('groups:createtime', 0, -1, function(err, groups) { async.waterfall([
if (err) { function(next) {
return callback(err); db.getSortedSetRange('groups:createtime', 0, -1, next);
} },
function(groups, next) {
async.each(groups, function(groupName, next) { async.each(groups, function(groupName, next) {
async.parallel([
function(next) {
Groups.isMember(uid, groupName, function(err, isMember) { Groups.isMember(uid, groupName, function(err, isMember) {
if (!err && isMember) { if (!err && isMember) {
Groups.leave(groupName, uid, next); Groups.leave(groupName, uid, next);
@ -175,8 +178,14 @@ module.exports = function(Groups) {
next(); next();
} }
}); });
}, callback); },
}); function(next) {
Groups.rejectMembership(groupName, uid, next);
}
], next);
}, next);
}
], callback);
}; };
Groups.getMembers = function(groupName, start, stop, callback) { Groups.getMembers = function(groupName, start, stop, callback) {

Loading…
Cancel
Save