admins can bypass the request step of a group and just join it, and they also become owners when they join a group

This commit is contained in:
Julian Lam
2015-01-22 16:01:17 -05:00
parent a526577927
commit 0c2d2a28ba
2 changed files with 25 additions and 6 deletions

View File

@@ -631,10 +631,23 @@ var async = require('async'),
Groups.exists(groupName, function(err, exists) {
if (exists) {
db.sortedSetAdd('group:' + groupName + ':members', Date.now(), uid, callback);
plugins.fireHook('action:group.join', {
groupName: groupName,
uid: uid
var tasks = [
async.apply(db.sortedSetAdd, 'group:' + groupName + ':members', Date.now(), uid)
];
user.isAdministrator(uid, function(err, isAdmin) {
if (isAdmin) {
tasks.push(async.apply(db.setAdd, 'group:' + groupName + ':owners', uid));
}
async.parallel(tasks, function(err) {
plugins.fireHook('action:group.join', {
groupName: groupName,
uid: uid
});
callback();
});
});
} else {
Groups.create({