if you attempt to join a group when you're already in a group, you can't anymore.

v1.18.x
Julian Lam 10 years ago
parent 8ba05c08fe
commit 04be40158c

@ -65,6 +65,7 @@
"group-name-too-short": "Group name too short",
"group-already-exists": "Group already exists",
"group-name-change-not-allowed": "Group name change not allowed",
"group-already-member": "You are already part of this group",
"post-already-deleted": "This post has already been deleted",
"post-already-restored": "This post has already been restored",

@ -615,15 +615,26 @@ var async = require('async'),
};
Groups.requestMembership = function(groupName, uid, callback) {
if (parseInt(uid, 10) > 0) {
db.setAdd('group:' + groupName + ':pending', uid, callback);
plugins.fireHook('action:group.requestMembership', {
groupName: groupName,
uid: uid
});
} else {
callback(new Error('[[error:not-logged-in]]'));
}
async.parallel({
exists: async.apply(Groups.isMember, uid, groupName),
isMember: async.apply(Groups.exists, groupName)
}, function(err, checks) {
if (!checks.exists) {
return callback(new Error('[[error:no-group]]'));
} else if (checks.isMember) {
return callback(new Error('[[error:group-already-member]]'));
}
if (parseInt(uid, 10) > 0) {
db.setAdd('group:' + groupName + ':pending', uid, callback);
plugins.fireHook('action:group.requestMembership', {
groupName: groupName,
uid: uid
});
} else {
callback(new Error('[[error:not-logged-in]]'));
}
});
};
Groups.acceptMembership = function(groupName, uid, callback) {

Loading…
Cancel
Save