|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
var async = require('async'),
|
|
|
|
|
|
|
|
|
|
winston = require('winston'),
|
|
|
|
|
db = require('./database'),
|
|
|
|
|
posts = require('./posts'),
|
|
|
|
|
user = require('./user'),
|
|
|
|
@ -44,11 +44,8 @@ var async = require('async'),
|
|
|
|
|
|
|
|
|
|
db.sortedSetAdd('users:reputation', newreputation, postData.uid);
|
|
|
|
|
|
|
|
|
|
if (parseInt(meta.config['autoban:downvote'], 10) === 1 && newreputation < parseInt(meta.config['autoban:downvote:threshold'], 10)) {
|
|
|
|
|
var adminUser = require('./socket.io/admin/user');
|
|
|
|
|
adminUser.banUser(postData.uid, function() {
|
|
|
|
|
require('winston').info('uid ' + uid + ' was banned for reaching ' + newreputation + ' reputation');
|
|
|
|
|
});
|
|
|
|
|
if (type === 'downvote') {
|
|
|
|
|
banUserForLowReputation(postData.uid, newreputation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
adjustPostVotes(pid, uid, type, unvote, function(err, votes) {
|
|
|
|
@ -66,6 +63,23 @@ var async = require('async'),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function banUserForLowReputation(uid, newreputation) {
|
|
|
|
|
if (parseInt(meta.config['autoban:downvote'], 10) === 1 && newreputation < parseInt(meta.config['autoban:downvote:threshold'], 10)) {
|
|
|
|
|
user.getUserField(uid, 'banned', function(err, banned) {
|
|
|
|
|
if (err || parseInt(banned, 10) === 1) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var adminUser = require('./socket.io/admin/user');
|
|
|
|
|
adminUser.banUser(uid, function(err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return winston.error(err.message);
|
|
|
|
|
}
|
|
|
|
|
winston.info('uid ' + uid + ' was banned for reaching ' + newreputation + ' reputation');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function adjustPostVotes(pid, uid, type, unvote, callback) {
|
|
|
|
|
var notType = (type === 'upvote' ? 'downvote' : 'upvote');
|
|
|
|
|
|
|
|
|
|