diff --git a/src/categories.js b/src/categories.js index 538bc0d5c3..a9d2138b5d 100644 --- a/src/categories.js +++ b/src/categories.js @@ -229,7 +229,7 @@ var db = require('./database.js'), return; } - posts.getPostSummaryByPids(pids, function(err, postData) { + posts.getPostSummaryByPids(pids, true, function(err, postData) { if (postData.length > count) { postData = postData.slice(0, count); } diff --git a/src/posts.js b/src/posts.js index c496afdd99..a9ab69f9d4 100644 --- a/src/posts.js +++ b/src/posts.js @@ -205,7 +205,7 @@ var db = require('./database'), Posts.addUserInfoToPost = function(post, callback) { user.getUserFields(post.uid, ['username', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned'], function(err, userData) { if (err) { - return callback(); + return callback(err); } postTools.parseSignature(userData.signature, function(err, signature) { @@ -242,7 +242,7 @@ var db = require('./database'), }); }; - Posts.getPostSummaryByPids = function(pids, callback) { + Posts.getPostSummaryByPids = function(pids, stripTags, callback) { var posts = []; @@ -283,10 +283,17 @@ var db = require('./database'), function(postData, next) { if (postData.content) { postTools.parse(postData.content, function(err, content) { - if (!err) { + if(err) { + return next(err); + } + + if(stripTags) { postData.content = utils.strip_tags(content); + } else { + postData.content = content; } - next(err, postData); + + next(null, postData); }); } else { next(null, postData); @@ -504,7 +511,7 @@ var db = require('./database'), if (err) return callback(err, null); - Posts.getPostSummaryByPids(pids, function(err, posts) { + Posts.getPostSummaryByPids(pids, false, function(err, posts) { if (err) return callback(err, null); diff --git a/src/routes/api.js b/src/routes/api.js index 0bebd9f975..dde83ad9e8 100644 --- a/src/routes/api.js +++ b/src/routes/api.js @@ -2,6 +2,7 @@ var path = require('path'), nconf = require('nconf'), async = require('async'), + db = require('../database'), user = require('../user'), auth = require('./authentication'), topics = require('../topics'), @@ -232,7 +233,7 @@ var path = require('path'), return callback(err, null); } - posts.getPostSummaryByPids(pids, function (err, posts) { + posts.getPostSummaryByPids(pids, false, function (err, posts) { if (err){ return callback(err, null); }