mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 20:45:58 +01:00
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:
@@ -631,11 +631,24 @@ var async = require('async'),
|
|||||||
|
|
||||||
Groups.exists(groupName, function(err, exists) {
|
Groups.exists(groupName, function(err, exists) {
|
||||||
if (exists) {
|
if (exists) {
|
||||||
db.sortedSetAdd('group:' + groupName + ':members', Date.now(), uid, callback);
|
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', {
|
plugins.fireHook('action:group.join', {
|
||||||
groupName: groupName,
|
groupName: groupName,
|
||||||
uid: uid
|
uid: uid
|
||||||
});
|
});
|
||||||
|
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
Groups.create({
|
Groups.create({
|
||||||
name: groupName,
|
name: groupName,
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
var groups = require('../groups'),
|
var groups = require('../groups'),
|
||||||
meta = require('../meta'),
|
meta = require('../meta'),
|
||||||
|
user = require('../user'),
|
||||||
|
|
||||||
|
async = require('async'),
|
||||||
|
|
||||||
SocketGroups = {};
|
SocketGroups = {};
|
||||||
|
|
||||||
@@ -11,8 +14,11 @@ SocketGroups.join = function(socket, data, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (meta.config.allowPrivateGroups !== '0') {
|
if (meta.config.allowPrivateGroups !== '0') {
|
||||||
groups.isPrivate(data.groupName, function(err, isPrivate) {
|
async.parallel({
|
||||||
if (isPrivate) {
|
isAdmin: async.apply(user.isAdministrator, socket.uid),
|
||||||
|
isPrivate: async.apply(groups.isPrivate, data.groupName)
|
||||||
|
}, function(err, checks) {
|
||||||
|
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user