mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-06 20:41:17 +01:00
closes #3130
This commit is contained in:
@@ -337,4 +337,11 @@ module.exports = function(Groups) {
|
||||
}
|
||||
db.isSetMember('group:' + groupName + ':pending', uid, callback);
|
||||
};
|
||||
|
||||
Groups.getPending = function(groupName, callback) {
|
||||
if (!groupName) {
|
||||
return callback(null, []);
|
||||
}
|
||||
db.getSetMembers('group:' + groupName + ':pending', callback);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -102,6 +102,37 @@ SocketGroups.reject = function(socket, data, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
SocketGroups.acceptAll = function(socket, data, callback) {
|
||||
acceptRejectAll('accept', socket, data, callback);
|
||||
};
|
||||
|
||||
SocketGroups.rejectAll = function(socket, data, callback) {
|
||||
acceptRejectAll('reject', socket, data, callback);
|
||||
};
|
||||
|
||||
function acceptRejectAll(type, socket, data, callback) {
|
||||
if (!data) {
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
}
|
||||
|
||||
groups.ownership.isOwner(socket.uid, data.groupName, function(err, isOwner) {
|
||||
if (err || !isOwner) {
|
||||
return callback(err || new Error('[[error:no-privileges]]'));
|
||||
}
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
groups.getPending(data.groupName, next);
|
||||
},
|
||||
function(uids, next) {
|
||||
var method = type === 'accept' ? groups.acceptMembership : groups.rejectMembership;
|
||||
async.each(uids, function(uid, next) {
|
||||
method(data.groupName, uid, next);
|
||||
}, next);
|
||||
}
|
||||
], callback);
|
||||
});
|
||||
}
|
||||
|
||||
SocketGroups.acceptInvite = function(socket, data, callback) {
|
||||
if (!data) {
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
|
||||
Reference in New Issue
Block a user