diff --git a/src/categories/recentreplies.js b/src/categories/recentreplies.js index 47c00a0242..a240e68fad 100644 --- a/src/categories/recentreplies.js +++ b/src/categories/recentreplies.js @@ -53,11 +53,19 @@ module.exports = function(Categories) { results.tids = results.tids.concat(results.pinnedTids); async.map(results.tids, topics.getLatestUndeletedPid, function(err, topicPids) { + if (err) { + return callback(err); + } + pids = pids.concat(topicPids).filter(function(pid, index, array) { return !!pid && array.indexOf(pid) === index; }); posts.getPostSummaryByPids(pids, {stripTags: true}, function(err, posts) { + if (err) { + return callback(err); + } + posts = posts.sort(function(a, b) { return parseInt(b.timestamp, 10) - parseInt(a.timestamp, 10); }).slice(0, count); diff --git a/src/topics/posts.js b/src/topics/posts.js index a61e67915a..98934a2f33 100644 --- a/src/topics/posts.js +++ b/src/topics/posts.js @@ -157,7 +157,7 @@ module.exports = function(Topics) { next(parseInt(deleted, 10) === 0); }); }, function(pid) { - callback(null, pid ? pid : null); + callback(null, pid ? pid.toString() : null); }); }); };