dont let sending more than max invites via bulk invite

v1.18.x
Barış Soner Uşaklı 6 years ago
parent c4b23909df
commit 69c7260fe9

@ -288,22 +288,26 @@ SocketUser.invite = function (socket, email, callback) {
if (registrationType === 'admin-invite-only' && !isAdmin) {
return next(new Error('[[error:no-privileges]]'));
}
var max = parseInt(meta.config.maximumInvites, 10);
email = email.split(',').map(email => email.trim()).filter(Boolean);
async.eachSeries(email, function (email, next) {
async.waterfall([
function (next) {
if (max) {
user.getInvitesNumber(socket.uid, next);
} else {
next(null, 0);
}
},
function (invites, next) {
var max = parseInt(meta.config.maximumInvites, 10);
if (!isAdmin && max && invites >= max) {
return next(new Error('[[error:invite-maximum-met, ' + invites + ', ' + max + ']]'));
}
email = email.split(',').map(email => email.trim()).filter(Boolean);
async.eachSeries(email, function (email, next) {
user.sendInvitationEmail(socket.uid, email, next);
}, next);
},
], next);
}, next);
},
], callback);
};

Loading…
Cancel
Save