mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-09 02:37:01 +02:00
check for last owner on user kick from group
This commit is contained in:
@@ -413,4 +413,24 @@ module.exports = function(Groups) {
|
||||
}
|
||||
db.getSetMembers('group:' + groupName + ':pending', callback);
|
||||
};
|
||||
|
||||
Groups.kick = function(uid, groupName, isOwner, callback) {
|
||||
if (isOwner) {
|
||||
// If the owners set only contains one member, error out!
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
db.setCount('group:' + groupName + ':owners', next);
|
||||
},
|
||||
function (numOwners, next) {
|
||||
if (numOwners <= 1) {
|
||||
return next(new Error('[[error:group-needs-owner]]'));
|
||||
}
|
||||
Groups.leave(groupName, uid, callback);
|
||||
next();
|
||||
}
|
||||
], callback);
|
||||
} else {
|
||||
Groups.leave(groupName, uid, callback);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user