mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-06 15:42:52 +01:00
closes #5875
This commit is contained in:
@@ -251,6 +251,9 @@ module.exports = function (Groups) {
|
||||
next();
|
||||
}
|
||||
},
|
||||
function (next) {
|
||||
clearGroupTitleIfSet(groupName, uid, next);
|
||||
},
|
||||
function (next) {
|
||||
plugins.fireHook('action:group.leave', {
|
||||
groupName: groupName,
|
||||
@@ -261,6 +264,24 @@ module.exports = function (Groups) {
|
||||
], callback);
|
||||
};
|
||||
|
||||
function clearGroupTitleIfSet(groupName, uid, callback) {
|
||||
if (groupName === 'registered-users' || Groups.isPrivilegeGroup(groupName)) {
|
||||
return callback();
|
||||
}
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
db.getObjectField('user:' + uid, 'groupTitle', next);
|
||||
},
|
||||
function (groupTitle, next) {
|
||||
if (groupTitle === groupName) {
|
||||
db.deleteObjectField('user:' + uid, 'groupTitle', next);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
}
|
||||
], callback);
|
||||
}
|
||||
|
||||
Groups.leaveAllGroups = function (uid, callback) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
|
||||
Reference in New Issue
Block a user