mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 10:06:13 +01:00
Maximum invites, invites stored
Added the ability for admins to restrict the maximum amount of invites a user can make. Invites are stored and displayed in the registration queue admin page.
This commit is contained in:
@@ -267,14 +267,39 @@ SocketUser.loadMore = function(socket, data, callback) {
|
||||
|
||||
SocketUser.invite = function(socket, email, callback) {
|
||||
if (!email || !socket.uid) {
|
||||
return callback(new Error('[[error:invald-data]]'));
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
}
|
||||
|
||||
if (meta.config.registrationType !== 'invite-only') {
|
||||
return callback(new Error('[[error:forum-not-invite-only]]'));
|
||||
}
|
||||
|
||||
user.sendInvitationEmail(socket.uid, email, callback);
|
||||
var max = meta.config.maximumInvites;
|
||||
|
||||
if (max) {
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
user.getInvitesNumber(socket.uid, next);
|
||||
},
|
||||
function(invites, next) {
|
||||
user.isAdministrator(socket.uid, function(err, admin) {
|
||||
next(err, invites, admin);
|
||||
});
|
||||
},
|
||||
function(invites, admin, next) {
|
||||
console.log(admin, invites, max);
|
||||
if (!admin && invites > max) {
|
||||
return next(new Error('[[error:invite-maximum-met, ' + invites + ', ' + max + ']]'));
|
||||
}
|
||||
next();
|
||||
},
|
||||
function(next) {
|
||||
user.sendInvitationEmail(socket.uid, email, next);
|
||||
}
|
||||
], callback);
|
||||
} else {
|
||||
user.sendInvitationEmail(socket.uid, email, callback);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user