'use strict'; var async = require('async'); var db = require('../database'); var topics = require('../topics'); var plugins = require('../plugins'); module.exports = function(Categories) { Categories.getCategoryTopics = function(data, callback) { async.waterfall([ function (next) { plugins.fireHook('filter:category.topics.prepare', data, next); }, function (data, next) { Categories.getTopicIds(data.set, data.reverse, data.start, data.stop, next); }, function (tids, next) { topics.getTopicsByTids(tids, data.uid, next); }, function (topics, next) { if (!Array.isArray(topics) || !topics.length) { return next(null, {topics: [], uid: data.uid}); } for (var i=0; i