mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-17 18:10:42 +01:00
closes #3741
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
var async = require('async');
|
||||
var groups = require('../../groups'),
|
||||
Groups = {};
|
||||
|
||||
@@ -20,7 +21,17 @@ Groups.join = function(socket, data, callback) {
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
}
|
||||
|
||||
groups.join(data.groupName, data.uid, callback);
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
groups.isMember(data.uid, data.groupName, next);
|
||||
},
|
||||
function (isMember, next) {
|
||||
if (isMember) {
|
||||
return next(new Error('[[error:group-already-member]]'));
|
||||
}
|
||||
groups.join(data.groupName, data.uid, next);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
Groups.leave = function(socket, data, callback) {
|
||||
@@ -32,7 +43,17 @@ Groups.leave = function(socket, data, callback) {
|
||||
return callback(new Error('[[error:cant-remove-self-as-admin]]'));
|
||||
}
|
||||
|
||||
groups.leave(data.groupName, data.uid, callback);
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
groups.isMember(data.uid, data.groupName, next);
|
||||
},
|
||||
function (isMember, next) {
|
||||
if (!isMember) {
|
||||
return next(new Error('[[error:group-not-member]]'));
|
||||
}
|
||||
groups.leave(data.groupName, data.uid, next);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
Groups.update = function(socket, data, callback) {
|
||||
|
||||
Reference in New Issue
Block a user