From baf72249b6fd9127fa897bfcd9d10bbd4dfbc2eb Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 3 Sep 2014 12:54:26 -0400 Subject: [PATCH] made uid parameter optional in getPidIndex --- src/posts.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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);