attempting to join a private group causes the join to be pending, #2588

This commit is contained in:
Julian Lam
2015-01-08 16:50:31 -05:00
parent a5d7fee623
commit 71b41239ac
3 changed files with 42 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
"use strict";
var groups = require('../groups'),
meta = require('../meta'),
SocketGroups = {};
@@ -9,7 +10,17 @@ SocketGroups.join = function(socket, data, callback) {
return callback(new Error('[[error:invalid-data]]'));
}
groups.join(data.groupName, socket.uid, callback);
if (meta.config.allowPrivateGroups) {
groups.isPrivate(data.groupName, function(err, isPrivate) {
if (isPrivate) {
groups.requestMembership(data.groupName, socket.uid, callback);
} else {
groups.join(data.groupName, socket.uid, callback);
}
});
} else {
groups.join(data.groupName, socket.uid, callback);
}
};
SocketGroups.leave = function(socket, data, callback) {