mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
closes #5618
This commit is contained in:
@@ -148,7 +148,9 @@ module.exports = function (Groups) {
|
||||
async.parallel([
|
||||
async.apply(db.setRemove, 'group:' + groupName + ':pending', uid),
|
||||
async.apply(db.setRemove, 'group:' + groupName + ':invited', uid),
|
||||
], callback);
|
||||
], function (err) {
|
||||
callback(err);
|
||||
});
|
||||
};
|
||||
|
||||
Groups.invite = function (groupName, uid, callback) {
|
||||
|
||||
@@ -7,6 +7,7 @@ var meta = require('../meta');
|
||||
var user = require('../user');
|
||||
var utils = require('../utils');
|
||||
var groupsController = require('../controllers/groups');
|
||||
var events = require('../events');
|
||||
|
||||
var SocketGroups = module.exports;
|
||||
|
||||
@@ -104,19 +105,47 @@ SocketGroups.rescind = isOwner(function (socket, data, callback) {
|
||||
});
|
||||
|
||||
SocketGroups.accept = isOwner(function (socket, data, callback) {
|
||||
groups.acceptMembership(data.groupName, data.toUid, callback);
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
groups.acceptMembership(data.groupName, data.toUid, next);
|
||||
},
|
||||
function (next) {
|
||||
events.log({
|
||||
type: 'accept-membership',
|
||||
uid: socket.uid,
|
||||
ip: socket.ip,
|
||||
groupName: data.groupName,
|
||||
targetUid: data.toUid,
|
||||
});
|
||||
setImmediate(next);
|
||||
},
|
||||
], callback);
|
||||
});
|
||||
|
||||
SocketGroups.reject = isOwner(function (socket, data, callback) {
|
||||
groups.rejectMembership(data.groupName, data.toUid, callback);
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
groups.rejectMembership(data.groupName, data.toUid, next);
|
||||
},
|
||||
function (next) {
|
||||
events.log({
|
||||
type: 'reject-membership',
|
||||
uid: socket.uid,
|
||||
ip: socket.ip,
|
||||
groupName: data.groupName,
|
||||
targetUid: data.toUid,
|
||||
});
|
||||
setImmediate(next);
|
||||
},
|
||||
], callback);
|
||||
});
|
||||
|
||||
SocketGroups.acceptAll = isOwner(function (socket, data, callback) {
|
||||
acceptRejectAll(groups.acceptMembership, socket, data, callback);
|
||||
acceptRejectAll(SocketGroups.accept, socket, data, callback);
|
||||
});
|
||||
|
||||
SocketGroups.rejectAll = isOwner(function (socket, data, callback) {
|
||||
acceptRejectAll(groups.rejectMembership, socket, data, callback);
|
||||
acceptRejectAll(SocketGroups.reject, socket, data, callback);
|
||||
});
|
||||
|
||||
function acceptRejectAll(method, socket, data, callback) {
|
||||
@@ -126,7 +155,7 @@ function acceptRejectAll(method, socket, data, callback) {
|
||||
},
|
||||
function (uids, next) {
|
||||
async.each(uids, function (uid, next) {
|
||||
method(data.groupName, uid, next);
|
||||
method(socket, { groupName: data.groupName, toUid: uid }, next);
|
||||
}, next);
|
||||
},
|
||||
], callback);
|
||||
|
||||
Reference in New Issue
Block a user