updating groups so that members leave a group when it is deleted

This commit is contained in:
Julian Lam
2014-03-21 09:27:13 -04:00
parent ce867aec53
commit 4701eb1cee
3 changed files with 20 additions and 2 deletions

View File

@@ -178,6 +178,9 @@
},
function(next) {
db.setRemove('groups', groupName, next);
},
function(next) {
db.delete('group:' + groupName + ':members', next);
}
], callback);
};

View File

@@ -433,10 +433,11 @@ Upgrade.upgrade = function(callback) {
function(next) {
Groups.list({ showAllGroups: true }, function(err, groups) {
async.each(groups, function(group, next) {
// If empty, delete group
if (group.memberCount === 0) {
// If empty, delete group
Groups.destroy(group.name, next);
} else if (group.hidden && !isValidHiddenGroup.test(group.name)) {
// If invalidly named hidden group, delete
Groups.destroy(group.name, next);
} else {
next();