Permalink
Browse files

Downvoters are boomzilla alts. Fixes apapadimoulis/what-bugs#164.

  • Loading branch information...
BenLubar committed Sep 7, 2017
1 parent 48e9727 commit e498fcabbc69365477232349da4abc053bc739ea
Showing with 57 additions and 0 deletions.
  1. +57 −0 plugins/nodebb-plugin-tdwtf-customizations/index.js
@@ -8,10 +8,12 @@ var db = module.parent.require('./database');
var Categories = module.parent.require('./categories');
var Groups = module.parent.require('./groups');
var Posts = module.parent.require('./posts');
var SocketPosts = module.parent.require('./socket.io/posts');
var SocketPlugins = module.parent.require('./socket.io/plugins');
var Topics = module.parent.require('./topics');
var User = module.parent.require('./user');
var privileges = module.parent.require('./privileges');
var meta = module.parent.require('./meta');
var utils = module.parent.require('../public/src/utils');
var realLoggerAdd = winston.Logger.prototype.add;
@@ -36,6 +38,61 @@ uploadsController.upload = function(req, res, filesIterator) {
realUpload(req, res, filesIterator);
};
// Modifications documented inline:
SocketPosts.getVoters = function (socket, data, callback) {
if (!data || !data.pid || !data.cid) {
return callback(new Error('[[error:invalid-data]]'));
}
async.waterfall([
function (next) {
// Removed:
//if (parseInt(meta.config.votesArePublic, 10) !== 0) {
// return next(null, true);
//}
privileges.categories.isAdminOrMod(data.cid, socket.uid, next);
},
function (isAdminOrMod, next) {
// Removed:
//if (!isAdminOrMod) {
// return next(new Error('[[error:no-privileges]]'));
//}
async.parallel({
upvoteUids: function (next) {
db.getSetMembers('pid:' + data.pid + ':upvote', next);
},
downvoteUids: function (next) {
// Added:
if (!isAdminOrMod && parseInt(meta.config.votesArePublic, 10) !== 1) {
return db.setCount('pid:' + data.pid + ':downvote', function (err, count) {
next(err, Array(count).fill(14));
});
}
// End Added
db.getSetMembers('pid:' + data.pid + ':downvote', next);
},
}, next);
},
function (results, next) {
async.parallel({
upvoters: function (next) {
User.getUsersFields(results.upvoteUids, ['username', 'userslug', 'picture'], next);
},
upvoteCount: function (next) {
next(null, results.upvoteUids.length);
},
downvoters: function (next) {
User.getUsersFields(results.downvoteUids, ['username', 'userslug', 'picture'], next);
},
downvoteCount: function (next) {
next(null, results.downvoteUids.length);
},
}, next);
},
], callback);
};
SocketPlugins.tdwtf = {};
SocketPlugins.tdwtf.getPopcornBookmark = function(socket, data, callback) {
var tid = parseInt(data, 10);

0 comments on commit e498fca

Please sign in to comment.