Skip to content

Node.js based forum software built for the modern web

closes #1934

barisusakli603cddc687d2
diff --git a/public/language/en_GB/error.json b/public/language/en_GB/error.json
index c9de71d2f4..b0ed8eeb5d 100644
--- a/public/language/en_GB/error.json
+++ b/public/language/en_GB/error.json
@@ -76,6 +76,8 @@
"cant-chat-with-yourself": "You can't chat with yourself!",
+ "reputation-system-disabled": "Reputation system is disabled.",
+ "downvoting-disabled": "Downvoting is disabled",
"not-enough-reputation-to-downvote": "You do not have enough reputation to downvote this post",
"reload-failed": "NodeBB encountered a problem while reloading: \"%1\". NodeBB will continue to serve the existing client-side assets, although you should undo what you did just prior to reloading."
diff --git a/src/controllers/topics.js b/src/controllers/topics.js
index 0c7aef7e38..e482efd412 100644
--- a/src/controllers/topics.js
+++ b/src/controllers/topics.js
@@ -184,8 +184,9 @@ topicsController.get = function(req, res, next) {
}
data.privileges = userPrivileges;
- data['reputation:disabled'] = meta.config['reputation:disabled'] === '1' ? true : false;
- data['feeds:disableRSS'] = meta.config['feeds:disableRSS'] === '1' ? true : false;
+ data['reputation:disabled'] = parseInt(meta.config['reputation:disabled'], 10) === 1;
+ data['downvote:disabled'] = parseInt(meta.config['downvote:disabled'], 10) === 1;
+ data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1;
var topic_url = tid + (req.params.slug ? '/' + req.params.slug : '');
var queryString = qs.stringify(req.query);
diff --git a/src/favourites.js b/src/favourites.js
index 64de4fa32f..50957c323f 100644
--- a/src/favourites.js
+++ b/src/favourites.js
@@ -98,20 +98,28 @@ var async = require('async'),
}
Favourites.upvote = function(pid, uid, callback) {
- if (meta.config['reputation:disabled'] === false) {
- return callback(false);
+ if (parseInt(meta.config['reputation:disabled'], 10) === 1) {
+ return callback(new Error('[[error:reputation-system-disabled]]'));
}
toggleVote('upvote', pid, uid, callback);
};
Favourites.downvote = function(pid, uid, callback) {
- if (meta.config['reputation:disabled'] === false) {
- return callback(false);
+ if (parseInt(meta.config['reputation:disabled'], 10) === 1) {
+ return callback(new Error('[[error:reputation-system-disabled]]'));
+ }
+
+ if (parseInt(meta.config['downvote:disabled'], 10) === 1) {
+ return callback(new Error('[[error:downvoting-disabled]]'));
}
user.getUserField(uid, 'reputation', function(err, reputation) {
- if (reputation < meta.config['privileges:downvote']) {
+ if (err) {
+ return callback(err);
+ }
+
+ if (reputation < parseInt(meta.config['privileges:downvote'], 10)) {
return callback(new Error('[[error:not-enough-reputation-to-downvote]]'));
}