Node.js based forum software built for the modern web
minor tweaks
barisusakli7b49effc14b1
diff --git a/src/postTools.js b/src/postTools.jsindex b157ead650..692878734a 100644--- a/src/postTools.js+++ b/src/postTools.js@@ -43,12 +43,15 @@ var winston = require('winston'),async.parallel({post: function(next) {- posts.setPostFields(data.pid, {+ var d = {edited: Date.now(),editor: data.uid,- handle: data.handle,content: postData.content- }, next);+ };+ if (data.handle) {+ d.handle = data.handle;+ }+ posts.setPostFields(data.pid, d, next);},topic: function(next) {var tid = postData.tid;diff --git a/src/posts/create.js b/src/posts/create.jsindex 198b9baae4..a235b2f3f0 100644--- a/src/posts/create.js+++ b/src/posts/create.js@@ -14,7 +14,6 @@ module.exports = function(Posts) {Posts.create = function(data, callback) {var uid = data.uid,tid = data.tid,- handle = data.uid ? null : data.handle, // Only guests have handles!content = data.content,timestamp = data.timestamp || Date.now();@@ -51,8 +50,8 @@ module.exports = function(Posts) {postData.ip = data.ip;}- if (handle) {- postData.handle = handle;+ if (parseInt(uid, 10) === 0 && data.handle) {+ postData.handle = data.handle;}plugins.fireHook('filter:post.save', postData, next);diff --git a/src/topics/create.js b/src/topics/create.jsindex 9fd7354b17..415c3b955a 100644--- a/src/topics/create.js+++ b/src/topics/create.js@@ -155,7 +155,7 @@ module.exports = function(Topics) {});},topicData: function(next) {- Topics.getTopicsByTids([postData.tid], 0, next);+ Topics.getTopicsByTids([postData.tid], uid, next);}}, next);},diff --git a/src/topics/posts.js b/src/topics/posts.jsindex c6e7829e5d..66fbb6bc4a 100644--- a/src/topics/posts.js+++ b/src/topics/posts.js@@ -108,15 +108,15 @@ module.exports = function(Topics) {posts.getPostIndices(postData, uid, next);}}, function(err, results) {- if(err) {+ if (err) {return callback(err);}- postData = postData.map(function(postObj, i) {+ postData.forEach(function(postObj, i) {if (postObj) {postObj.index = results.indices[i];postObj.deleted = parseInt(postObj.deleted, 10) === 1;- postObj.user = _.clone(results.userData[postObj.uid]);+ postObj.user = parseInt(postObj.uid, 10) ? results.userData[postObj.uid] : _.clone(results.userData[postObj.uid]);postObj.editor = postObj.editor ? results.editors[postObj.editor] : null;postObj.favourited = results.favourites[i];postObj.upvoted = results.voteData.upvotes[i];@@ -135,9 +135,7 @@ module.exports = function(Topics) {postObj.user.username = postObj.handle;}}-- return postObj;- }).filter(Boolean);+ });callback(null, postData);});