Node.js based forum software built for the modern web
closes #2028
barisusakli14fcd361344b
diff --git a/public/language/en_GB/error.json b/public/language/en_GB/error.jsonindex b0ed8eeb5d..7c457eb497 100644--- a/public/language/en_GB/error.json+++ b/public/language/en_GB/error.json@@ -79,6 +79,7 @@"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",+ "not-enough-reputation-to-flag": "Yo do not have enough reputation to flag 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."}\ No newline at end of filediff --git a/src/socket.io/posts.js b/src/socket.io/posts.jsindex 5326fc09de..7a825dccd0 100644--- a/src/socket.io/posts.js+++ b/src/socket.io/posts.js@@ -276,16 +276,22 @@ SocketPosts.flag = function(socket, pid, callback) {async.waterfall([function(next) {- user.getUserField(socket.uid, 'username', next);+ user.getUserFields(socket.uid, ['username', 'reputation'], next);},- function(username, next) {- message = '[[notifications:user_flagged_post, ' + username + ']]';+ function(userData, next) {+ if (parseInt(userData.reputation, 10) < parseInt(meta.config['privileges:flag'] || 1, 10)) {+ return next(new Error('[[error:not-enough-reputation-to-flag]]'));+ }+ message = '[[notifications:user_flagged_post, ' + userData.username + ']]';posts.getPostFields(pid, ['tid', 'uid', 'content'], next);},function(postData, next) {postTools.parse(postData.content, function(err, parsed) {+ if (err) {+ return next(err);+ }postData.content = parsed;- next(undefined, postData);+ next(null, postData);});},function(postData, next) {diff --git a/src/topics/posts.js b/src/topics/posts.jsindex 35e33b530d..a3366d6c40 100644--- a/src/topics/posts.js+++ b/src/topics/posts.js@@ -106,6 +106,7 @@ module.exports = function(Topics) {for (var i = 0; i < postData.length; ++i) {if (postData[i]) {+ postData[i].index = results.indices[i];postData[i].deleted = parseInt(postData[i].deleted, 10) === 1;postData[i].user = results.userData[postData[i].uid];postData[i].editor = postData[i].editor ? results.editors[postData[i].editor] : null;diff --git a/src/user/notifications.js b/src/user/notifications.jsindex 9d43845b9c..c71238366e 100644--- a/src/user/notifications.js+++ b/src/user/notifications.js@@ -12,7 +12,8 @@ var async = require('async'),posts = require('../posts'),postTools = require('../postTools'),topics = require('../topics'),- privileges = require('../privileges');+ privileges = require('../privileges'),+ utils = require('../../public/src/utils');(function(UserNotifications) {@@ -186,7 +187,8 @@ var async = require('async'),var paths = [];pids.forEach(function(pid, index) {var slug = results.topics[index] ? results.topics[index].slug : null;- var postIndex = results.indices[index] ? parseInt(results.indices[index], 10) + 1 : null;+ var postIndex = utils.isNumber(results.indices[index]) ? parseInt(results.indices[index], 10) + 1 : null;+if (slug && postIndex) {paths.push(nconf.get('relative_path') + '/topic/' + slug + '/' + postIndex);} else {