'use strict'; var async = require('async'), db = require('../database'), user = require('../user'), topics = require('../topics'), plugins = require('../plugins'); module.exports = function(Categories) { Categories.getCategoryTopics = function(data, callback) { async.parallel({ isAdmin: function(next) { user.isAdministrator(data.uid, next); }, isModerator: function(next) { user.isModerator(data.uid, data.cid, next); }, topics: function(next) { 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