diff --git a/src/categories/recentreplies.js b/src/categories/recentreplies.js index c38fec527e..564d05d673 100644 --- a/src/categories/recentreplies.js +++ b/src/categories/recentreplies.js @@ -86,7 +86,7 @@ module.exports = function (Categories) { privileges.topics.filterTids('read', tids, uid, next); }, function (tids, next) { - getTopics(tids, next); + getTopics(tids, uid, next); }, function (topics, next) { assignTopicsToCategories(categoryData, topics); @@ -98,7 +98,7 @@ module.exports = function (Categories) { ], callback); }; - function getTopics(tids, callback) { + function getTopics(tids, uid, callback) { var topicData; async.waterfall([ function (next) { @@ -119,7 +119,7 @@ module.exports = function (Categories) { async.parallel({ categoryData: async.apply(Categories.getCategoriesFields, cids, ['cid', 'parentCid']), - teasers: async.apply(topics.getTeasers, _topicData), + teasers: async.apply(topics.getTeasers, _topicData, uid), }, next); }, function (results, next) { diff --git a/src/topics.js b/src/topics.js index 164200016d..ed7deacc2e 100644 --- a/src/topics.js +++ b/src/topics.js @@ -126,7 +126,7 @@ var social = require('./social'); Topics.getUserBookmarks(tids, uid, next); }, teasers: function (next) { - Topics.getTeasers(topics, next); + Topics.getTeasers(topics, uid, next); }, tags: function (next) { Topics.getTopicsTagsObjects(tids, next); diff --git a/src/topics/teaser.js b/src/topics/teaser.js index aa64d7780f..b990b608d1 100644 --- a/src/topics/teaser.js +++ b/src/topics/teaser.js @@ -12,7 +12,11 @@ var plugins = require('../plugins'); var utils = require('../../public/src/utils'); module.exports = function (Topics) { - Topics.getTeasers = function (topics, callback) { + Topics.getTeasers = function (topics, uid, callback) { + if (typeof uid === 'function') { + callback = uid; + uid = 0; + } if (!Array.isArray(topics) || !topics.length) { return callback(null, []); } @@ -94,7 +98,7 @@ module.exports = function (Topics) { return tidToPost[topic.tid]; }); - plugins.fireHook('filter:teasers.get', { teasers: teasers }, next); + plugins.fireHook('filter:teasers.get', { teasers: teasers, uid: uid }, next); }, function (data, next) { next(null, data.teasers); @@ -102,7 +106,11 @@ module.exports = function (Topics) { ], callback); }; - Topics.getTeasersByTids = function (tids, callback) { + Topics.getTeasersByTids = function (tids, uid, callback) { + if (typeof uid === 'function') { + callback = uid; + uid = 0; + } if (!Array.isArray(tids) || !tids.length) { return callback(null, []); } @@ -111,13 +119,17 @@ module.exports = function (Topics) { Topics.getTopicsFields(tids, ['tid', 'postcount', 'teaserPid'], next); }, function (topics, next) { - Topics.getTeasers(topics, next); + Topics.getTeasers(topics, uid, next); }, ], callback); }; - Topics.getTeaser = function (tid, callback) { - Topics.getTeasersByTids([tid], function (err, teasers) { + Topics.getTeaser = function (tid, uid, callback) { + if (typeof uid === 'function') { + callback = uid; + uid = 0; + } + Topics.getTeasersByTids([tid], uid, function (err, teasers) { callback(err, Array.isArray(teasers) && teasers.length ? teasers[0] : null); }); };