diff --git a/src/categories.js b/src/categories.js index 675eb4a80b..574e435081 100644 --- a/src/categories.js +++ b/src/categories.js @@ -64,9 +64,7 @@ var async = require('async'), category.isIgnored = results.isIgnored[0]; category.topic_row_size = 'col-md-9'; - plugins.fireHook('filter:category.get', {category: category, uid: data.uid}, function(err, data) { - callback(err, data ? data.category : null); - }); + callback(null, category); }); }); }; diff --git a/src/controllers/categories.js b/src/controllers/categories.js index 75b80a17d0..06b2b957fa 100644 --- a/src/controllers/categories.js +++ b/src/controllers/categories.js @@ -22,12 +22,7 @@ categoriesController.recent = function(req, res, next) { data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1; - plugins.fireHook('filter:category.get', {category: data, uid: uid}, function(err, data) { - if (err) { - return next(err); - } - res.render('recent', data.category); - }); + res.render('recent', data); }); }; @@ -49,24 +44,22 @@ categoriesController.popular = function(req, res, next) { } } - topics.getPopular(term, uid, meta.config.topicsPerList, function(err, data) { + topics.getPopular(term, uid, meta.config.topicsPerList, function(err, topics) { if (err) { return next(err); } - data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1; + var data = { + topics: topics, + 'feeds:disableRSS': parseInt(meta.config['feeds:disableRSS'], 10) === 1 + }; - plugins.fireHook('filter:category.get', {category: {topics: data}, uid: uid}, function(err, data) { - if (err) { - return next(err); - } - if (uid === 0) { - anonCache[term] = data.category; - lastUpdateTime = Date.now(); - } + if (uid === 0) { + anonCache[term] = data; + lastUpdateTime = Date.now(); + } - res.render('popular', data.category); - }); + res.render('popular', data); }); }; @@ -78,12 +71,7 @@ categoriesController.unread = function(req, res, next) { return next(err); } - plugins.fireHook('filter:category.get', {category: data, uid: uid}, function(err, data) { - if (err) { - return next(err); - } - res.render('unread', data.category); - }); + res.render('unread', data); }); }; diff --git a/src/topics/popular.js b/src/topics/popular.js index 1f8ff31bf3..ce2182cabf 100644 --- a/src/topics/popular.js +++ b/src/topics/popular.js @@ -32,24 +32,21 @@ module.exports = function(Topics) { } function getTopics(tids, uid, count, callback) { - Topics.getTopicsFields(tids, ['tid', 'postcount'], function(err, topics) { - if (err) { - return callback(err); + async.waterfall([ + function(next) { + Topics.getTopicsFields(tids, ['tid', 'postcount'], next); + }, + function(topics, next) { + tids = topics.sort(function(a, b) { + return b.postcount - a.postcount; + }).slice(0, count).map(function(topic) { + return topic.tid; + }); + privileges.topics.filter('read', tids, uid, next); + }, + function(tids, next) { + Topics.getTopicsByTids(tids, uid, next); } - - tids = topics.sort(function(a, b) { - return b.postcount - a.postcount; - }).slice(0, count).map(function(topic) { - return topic.tid; - }); - - privileges.topics.filter('read', tids, uid, function(err, tids) { - if (err) { - return callback(err); - } - - Topics.getTopicsByTids(tids, uid, callback); - }); - }); + ], callback); } };