Skip to content

Node.js based forum software built for the modern web

closes #5618

Barış Soner Uşaklı5e90e4db0240
diff --git a/src/groups/membership.js b/src/groups/membership.js
index 244c3e6695..45f16ea607 100644
--- a/src/groups/membership.js
+++ b/src/groups/membership.js
@@ -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) {
diff --git a/src/socket.io/groups.js b/src/socket.io/groups.js
index 83ca8b1383..8a446f563c 100644
--- a/src/socket.io/groups.js
+++ b/src/socket.io/groups.js
@@ -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);