sending in groupObj data into group.delete hook

This commit is contained in:
Julian Lam
2015-01-15 14:09:20 -05:00
parent 6b5b0b9eec
commit 8d23265324

View File

@@ -556,31 +556,27 @@ var async = require('async'),
} }
Groups.destroy = function(groupName, callback) { Groups.destroy = function(groupName, callback) {
async.parallel([ Groups.get(groupName, {}, function(err, groupObj) {
async.apply(db.delete, 'group:' + groupName), plugins.fireHook('action:group.destroy', groupObj);
async.apply(db.setRemove, 'groups', groupName),
async.apply(db.delete, 'group:' + groupName + ':members'),
async.apply(db.delete, 'group:' + groupName + ':pending'),
async.apply(db.delete, 'group:' + groupName + ':owners'),
function(next) {
db.getSetMembers('groups', function(err, groups) {
if (err) {
return next(err);
}
async.each(groups, function(group, next) {
db.setRemove('group:' + group + ':members', groupName, next);
}, next);
});
}
], function(err) {
if (!err) {
plugins.fireHook('action:group.destroy', {
name: groupName
});
}
callback(err); async.parallel([
}); async.apply(db.delete, 'group:' + groupName),
async.apply(db.setRemove, 'groups', groupName),
async.apply(db.delete, 'group:' + groupName + ':members'),
async.apply(db.delete, 'group:' + groupName + ':pending'),
async.apply(db.delete, 'group:' + groupName + ':owners'),
function(next) {
db.getSetMembers('groups', function(err, groups) {
if (err) {
return next(err);
}
async.each(groups, function(group, next) {
db.setRemove('group:' + group + ':members', groupName, next);
}, next);
});
}
], callback);
})
}; };
Groups.join = function(groupName, uid, callback) { Groups.join = function(groupName, uid, callback) {