mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 05:55:48 +01:00
if you attempt to join a group when you're already in a group, you can't anymore.
This commit is contained in:
@@ -65,6 +65,7 @@
|
|||||||
"group-name-too-short": "Group name too short",
|
"group-name-too-short": "Group name too short",
|
||||||
"group-already-exists": "Group already exists",
|
"group-already-exists": "Group already exists",
|
||||||
"group-name-change-not-allowed": "Group name change not allowed",
|
"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-deleted": "This post has already been deleted",
|
||||||
"post-already-restored": "This post has already been restored",
|
"post-already-restored": "This post has already been restored",
|
||||||
|
|||||||
@@ -615,6 +615,16 @@ var async = require('async'),
|
|||||||
};
|
};
|
||||||
|
|
||||||
Groups.requestMembership = function(groupName, uid, callback) {
|
Groups.requestMembership = function(groupName, uid, callback) {
|
||||||
|
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) {
|
if (parseInt(uid, 10) > 0) {
|
||||||
db.setAdd('group:' + groupName + ':pending', uid, callback);
|
db.setAdd('group:' + groupName + ':pending', uid, callback);
|
||||||
plugins.fireHook('action:group.requestMembership', {
|
plugins.fireHook('action:group.requestMembership', {
|
||||||
@@ -624,6 +634,7 @@ var async = require('async'),
|
|||||||
} else {
|
} else {
|
||||||
callback(new Error('[[error:not-logged-in]]'));
|
callback(new Error('[[error:not-logged-in]]'));
|
||||||
}
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Groups.acceptMembership = function(groupName, uid, callback) {
|
Groups.acceptMembership = function(groupName, uid, callback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user