diff --git a/src/posts.js b/src/posts.js index 10d299b4b3..96a00f1397 100644 --- a/src/posts.js +++ b/src/posts.js @@ -532,10 +532,20 @@ var async = require('async'), } Posts.getPidIndex = function(pid, uid, callback) { - callback = callback || function() {}; + // Making uid optional + if ((!uid && !callback) || typeof uid === 'function') { + callback = uid; + uid = undefined; + } + async.parallel({ settings: function(next) { - user.getSettings(uid, next); + if (uid) { + user.getSettings(uid, next); + } else { + // No uid specified, so return empty object so that the check below will assume regular topic post sorting + next(null, {}); + } }, tid: function(next) { Posts.getPostField(pid, 'tid', next);