Aziz Khoury 6 years ago committed by Julian Lam
parent e0fa696554
commit 04232986ab

@ -1,8 +1,6 @@
'use strict'; 'use strict';
var async = require('async'); var async = require('async');
var request = require('request');
var winston = require('winston');
var validator = require('validator'); var validator = require('validator');
var db = require('../database'); var db = require('../database');
@ -197,16 +195,9 @@ module.exports = function (User) {
async.map(users, function (user, next) { async.map(users, function (user, next) {
// temporary: see http://www.stopforumspam.com/forum/viewtopic.php?id=6392 // temporary: see http://www.stopforumspam.com/forum/viewtopic.php?id=6392
// need to keep this for getIPMatchedUsers
user.ip = user.ip.replace('::ffff:', ''); user.ip = user.ip.replace('::ffff:', '');
getIPMatchedUsers(user, function (err) {
async.parallel([
function (next) {
getIPMatchedUsers(user, next);
},
function (next) {
getSpamData(user, next);
},
], function (err) {
next(err, user); next(err, user);
}); });
}, next); }, next);
@ -234,34 +225,4 @@ module.exports = function (User) {
}, },
], callback); ], callback);
} }
function getSpamData(user, callback) {
async.waterfall([
function (next) {
request({
method: 'get',
url: 'http://api.stopforumspam.org/api' +
'?ip=' + encodeURIComponent(user.ip) +
'&email=' + encodeURIComponent(user.email) +
'&username=' + encodeURIComponent(user.username) +
'&f=json',
json: true,
}, next);
},
function (response, body, next) {
if (response.statusCode === 200 && body) {
user.spamData = body;
user.usernameSpam = body.username ? (body.username.frequency > 0 || body.username.appears > 0) : true;
user.emailSpam = body.email ? (body.email.frequency > 0 || body.email.appears > 0) : true;
user.ipSpam = body.ip ? (body.ip.frequency > 0 || body.ip.appears > 0) : true;
}
next();
},
], function (err) {
if (err) {
winston.error(err);
}
callback();
});
}
}; };

Loading…
Cancel
Save