Node.js based forum software built for the modern web
fix moderators
barisusakli420aa5e10282
diff --git a/src/categories.js b/src/categories.jsindex d0d11c7981..46c9fe18bd 100644--- a/src/categories.js+++ b/src/categories.js@@ -84,22 +84,19 @@ var async = require('async'),};Categories.getPageCount = function(cid, uid, callback) {- Categories.getCategoryField(cid, 'topic_count', function(err, topicCount) {+ async.parallel({+ topicCount: async.apply(Categories.getCategoryField, cid, 'topic_count'),+ settings: async.apply(user.getSettings, uid)+ }, function(err, results) {if (err) {return callback(err);}- if (parseInt(topicCount, 10) === 0) {+ if (!parseInt(results.topicCount, 10)) {return callback(null, 1);}- user.getSettings(uid, function(err, settings) {- if (err) {- return callback(err);- }-- callback(null, Math.ceil(parseInt(topicCount, 10) / settings.topicsPerPage));- });+ callback(null, Math.ceil(parseInt(results.topicCount, 10) / results.settings.topicsPerPage));});};@@ -118,49 +115,32 @@ var async = require('async'),};Categories.getCategoriesByPrivilege = function(uid, privilege, callback) {- db.getSortedSetRange('categories:cid', 0, -1, function(err, cids) {- if (err) {- return callback(err);- }-- if (!Array.isArray(cids) || !cids.length) {- return callback(null, []);- }-- privileges.categories.filterCids(privilege, cids, uid, function(err, cids) {- if (err) {- return callback(err);- }-- Categories.getCategories(cids, uid, function(err, categories) {- if (err) {- return callback(err);- }-- categories = categories.filter(function(category) {- return !category.disabled;- });-- callback(null, categories);+ async.waterfall([+ function(next) {+ db.getSortedSetRange('categories:cid', 0, -1, next);+ },+ function(cids, next) {+ privileges.categories.filterCids(privilege, cids, uid, next);+ },+ function(cids, next) {+ Categories.getCategories(cids, uid, next);+ },+ function(categories, next) {+ categories = categories.filter(function(category) {+ return !category.disabled;});- });- });+ next(null, categories);+ }+ ], callback);};Categories.getModerators = function(cid, callback) {- Groups.get('cid:' + cid + ':privileges:mods', {}, function(err, groupObj) {- if (err && err === 'group-not-found') {- return callback(null, []);- }- if (err) {+ Groups.getMembers('cid:' + cid + ':privileges:mods', function(err, uids) {+ if (err || !Array.isArray(uids) || !uids.length) {return callback(err);}- if (!Array.isArray(groupObj) || !groupObj.members.length) {- return callback(null, []);- }-- user.getMultipleUserFields(groupObj.members, ['uid', 'username', 'userslug', 'picture'], callback);+ user.getMultipleUserFields(uids, ['uid', 'username', 'userslug', 'picture'], callback);});};diff --git a/src/groups.js b/src/groups.jsindex 4f007f1eec..cbdc55c32b 100644--- a/src/groups.js+++ b/src/groups.js@@ -140,6 +140,10 @@ var async = require('async'),});};+ Groups.getMembers = function(groupName, callback) {+ db.getSetMembers('group:' + groupName + ':members', callback);+ };+Groups.search = function(query, options, callback) {if (!query) {return callback(null, []);diff --git a/src/privileges/categories.js b/src/privileges/categories.jsindex c957f1be6e..309404ac11 100644--- a/src/privileges/categories.js+++ b/src/privileges/categories.js@@ -70,7 +70,7 @@ module.exports = function(privileges) {};privileges.categories.filterCids = function(privilege, cids, uid, callback) {- if (!cids.length) {+ if (!Array.isArray(cids) || !cids.length) {return callback(null, []);}