mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
feat: let theme know downvoting is disabled, closes https://github.com/NodeBB/NodeBB/pull/7568
dont load downvote data if downvoting is disabled
This commit is contained in:
@@ -14,7 +14,7 @@ module.exports = function (SocketPosts) {
|
|||||||
if (!data || !data.pid || !data.cid) {
|
if (!data || !data.pid || !data.cid) {
|
||||||
return callback(new Error('[[error:invalid-data]]'));
|
return callback(new Error('[[error:invalid-data]]'));
|
||||||
}
|
}
|
||||||
|
const showDownvotes = !meta.config['downvote:disabled'];
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
if (meta.config.votesArePublic) {
|
if (meta.config.votesArePublic) {
|
||||||
@@ -32,6 +32,9 @@ module.exports = function (SocketPosts) {
|
|||||||
db.getSetMembers('pid:' + data.pid + ':upvote', next);
|
db.getSetMembers('pid:' + data.pid + ':upvote', next);
|
||||||
},
|
},
|
||||||
downvoteUids: function (next) {
|
downvoteUids: function (next) {
|
||||||
|
if (!showDownvotes) {
|
||||||
|
return setImmediate(next, null, []);
|
||||||
|
}
|
||||||
db.getSetMembers('pid:' + data.pid + ':downvote', next);
|
db.getSetMembers('pid:' + data.pid + ':downvote', next);
|
||||||
},
|
},
|
||||||
}, next);
|
}, next);
|
||||||
@@ -41,17 +44,17 @@ module.exports = function (SocketPosts) {
|
|||||||
upvoters: function (next) {
|
upvoters: function (next) {
|
||||||
user.getUsersFields(results.upvoteUids, ['username', 'userslug', 'picture'], next);
|
user.getUsersFields(results.upvoteUids, ['username', 'userslug', 'picture'], next);
|
||||||
},
|
},
|
||||||
upvoteCount: function (next) {
|
|
||||||
next(null, results.upvoteUids.length);
|
|
||||||
},
|
|
||||||
downvoters: function (next) {
|
downvoters: function (next) {
|
||||||
user.getUsersFields(results.downvoteUids, ['username', 'userslug', 'picture'], next);
|
user.getUsersFields(results.downvoteUids, ['username', 'userslug', 'picture'], next);
|
||||||
},
|
},
|
||||||
downvoteCount: function (next) {
|
|
||||||
next(null, results.downvoteUids.length);
|
|
||||||
},
|
|
||||||
}, next);
|
}, next);
|
||||||
},
|
},
|
||||||
|
function (results, next) {
|
||||||
|
results.upvoteCount = results.upvoters.length;
|
||||||
|
results.downvoteCount = results.downvoters.length;
|
||||||
|
results.showDownvotes = showDownvotes;
|
||||||
|
next(null, results);
|
||||||
|
}
|
||||||
], callback);
|
], callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user