|
|
|
@ -133,20 +133,10 @@ var async = require('async'),
|
|
|
|
|
|
|
|
|
|
putVoteInProgress(pid, uid);
|
|
|
|
|
|
|
|
|
|
user.getUserField(uid, 'reputation', function(err, reputation) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return callback(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (reputation < parseInt(meta.config['privileges:downvote'], 10)) {
|
|
|
|
|
return callback(new Error('[[error:not-enough-reputation-to-downvote]]'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
toggleVote('downvote', pid, uid, function(err, data) {
|
|
|
|
|
clearVoteProgress(pid, uid);
|
|
|
|
|
callback(err, data);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Favourites.unvote = function(pid, uid, callback) {
|
|
|
|
@ -197,6 +187,9 @@ var async = require('async'),
|
|
|
|
|
},
|
|
|
|
|
voteStatus: function(next) {
|
|
|
|
|
Favourites.hasVoted(pid, uid, next);
|
|
|
|
|
},
|
|
|
|
|
reputation: function(next) {
|
|
|
|
|
user.getUserField(uid, 'reputation', next);
|
|
|
|
|
}
|
|
|
|
|
}, function(err, results) {
|
|
|
|
|
if (err) {
|
|
|
|
@ -207,6 +200,10 @@ var async = require('async'),
|
|
|
|
|
return callback(new Error('self-vote'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (command === 'downvote' && parseInt(results.reputation) < parseInt(meta.config['privileges:downvote'], 10)) {
|
|
|
|
|
return callback(new Error('[[error:not-enough-reputation-to-downvote]]'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var voteStatus = results.voteStatus,
|
|
|
|
|
hook,
|
|
|
|
|
current = voteStatus.upvoted ? 'upvote' : 'downvote';
|
|
|
|
|