v1.18.x
Barış Soner Uşaklı 9 years ago
parent 879a8ba550
commit 99ae0eb378

@ -18,7 +18,6 @@
"autoprefixer": "^6.2.3",
"bcryptjs": "~2.3.0",
"body-parser": "^1.9.0",
"checksum": "^0.1.1",
"colors": "^1.1.0",
"compression": "^1.1.0",
"connect-ensure-login": "^0.1.1",

@ -77,10 +77,17 @@ usersController.banned = function(req, res, next) {
};
usersController.registrationQueue = function(req, res, next) {
var page = parseInt(req.query.page, 10) || 1;
var itemsPerPage = 20;
var start = (page - 1) * 20;
var stop = start + itemsPerPage - 1;
var invitations;
async.parallel({
registrationQueueCount: function(next) {
db.sortedSetCard('registration:queue', next);
},
users: function(next) {
user.getRegistrationQueue(0, -1, next);
user.getRegistrationQueue(start, stop, next);
},
invites: function(next) {
async.waterfall([
@ -118,6 +125,8 @@ usersController.registrationQueue = function(req, res, next) {
if (err) {
return next(err);
}
var pageCount = Math.max(1, Math.ceil(data.registrationQueueCount / itemsPerPage));
data.pagination = pagination.create(page, pageCount);
res.render('admin/manage/registration', data);
});
};
@ -146,7 +155,7 @@ function getUsers(set, section, req, res, next) {
var data = {
users: results.users,
page: page,
pageCount: Math.ceil(results.count / resultsPerPage)
pageCount: Math.max(1, Math.ceil(results.count / resultsPerPage))
};
data[section] = true;
render(req, res, data);

@ -3,8 +3,6 @@
var async = require('async');
var request = require('request');
var LRU = require('lru-cache');
var checksum = require('checksum');
var db = require('../database');
var meta = require('../meta');
@ -14,11 +12,6 @@ var groups = require('../groups');
var translator = require('../../public/src/modules/translator');
var utils = require('../../public/src/utils');
var sfsCache = LRU({
max: 500,
maxAge: 1000*60*60*24 // one day
});
module.exports = function(User) {
@ -165,22 +158,11 @@ module.exports = function(User) {
return user;
}).filter(Boolean);
async.mapLimit(users, 20, function(user, next) {
async.map(users, function(user, next) {
if (!user) {
return next(null, user);
}
var sum = checksum(user.ip+user.email+user.username);
if (sfsCache.has(sum)) {
var cached = sfsCache.get(sum);
user.spamData = cached;
user.usernameSpam = cached.username.frequency > 0 || cached.username.appears > 0;
user.emailSpam = cached.email.frequency > 0 || cached.email.appears > 0;
user.ipSpam = cached.ip.frequency > 0 || cached.ip.appears > 0;
return next(null, user);
}
// temporary: see http://www.stopforumspam.com/forum/viewtopic.php?id=6392
user.ip = user.ip.replace('::ffff:', '');
@ -197,7 +179,6 @@ module.exports = function(User) {
return next(null, user);
}
if (response.statusCode === 200) {
sfsCache.set(sum, body);
user.spamData = body;
user.usernameSpam = body.username.frequency > 0 || body.username.appears > 0;
user.emailSpam = body.email.frequency > 0 || body.email.appears > 0;

@ -55,6 +55,8 @@
</tr>
<!-- END users -->
</table>
<!-- IMPORT partials/paginator.tpl -->
</div>
<div class="invitations panel panel-success">

Loading…
Cancel
Save