mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
check group exists before joining
This commit is contained in:
@@ -22,20 +22,30 @@ SocketGroups.join = function(socket, data, callback) {
|
|||||||
return callback(new Error('[[error:invalid-uid]]'));
|
return callback(new Error('[[error:invalid-uid]]'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (meta.config.allowPrivateGroups !== '0') {
|
groups.exists(data.groupName, function(err, exists) {
|
||||||
|
if (err || !exists) {
|
||||||
|
return callback(err || new Error('[[error:no-group]]'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parseInt(meta.config.allowPrivateGroups, 10) !== 1) {
|
||||||
|
return groups.join(data.groupName, socket.uid, callback);
|
||||||
|
}
|
||||||
|
|
||||||
async.parallel({
|
async.parallel({
|
||||||
isAdmin: async.apply(user.isAdministrator, socket.uid),
|
isAdmin: async.apply(user.isAdministrator, socket.uid),
|
||||||
isPrivate: async.apply(groups.isPrivate, data.groupName)
|
isPrivate: async.apply(groups.isPrivate, data.groupName)
|
||||||
}, function(err, checks) {
|
}, function(err, checks) {
|
||||||
|
if (err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
|
||||||
if (checks.isPrivate && !checks.isAdmin) {
|
if (checks.isPrivate && !checks.isAdmin) {
|
||||||
groups.requestMembership(data.groupName, socket.uid, callback);
|
groups.requestMembership(data.groupName, socket.uid, callback);
|
||||||
} else {
|
} else {
|
||||||
groups.join(data.groupName, socket.uid, callback);
|
groups.join(data.groupName, socket.uid, callback);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
});
|
||||||
groups.join(data.groupName, socket.uid, callback);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SocketGroups.leave = function(socket, data, callback) {
|
SocketGroups.leave = function(socket, data, callback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user