From 5b67cd841e5cf89776771683956a7990c02bf2bc Mon Sep 17 00:00:00 2001 From: psychobunny Date: Fri, 27 Feb 2015 15:30:36 -0500 Subject: [PATCH] fire filter:config.get even if anonymous --- src/controllers/api.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/controllers/api.js b/src/controllers/api.js index 78e8fe2c75..c98fd79e0c 100644 --- a/src/controllers/api.js +++ b/src/controllers/api.js @@ -12,6 +12,16 @@ var pkg = require('./../../package.json'), var apiController = {}; apiController.getConfig = function(req, res, next) { + function filterConfig() { + plugins.fireHook('filter:config.get', config, function(err, config) { + if (res.locals.isAPI) { + res.status(200).json(config); + } else { + next(err, config); + } + }); + } + var config = {}; config.relative_path = nconf.get('relative_path'); config.socketioTransports = nconf.get('socket.io:transports') || ['polling', 'websocket']; @@ -63,12 +73,7 @@ apiController.getConfig = function(req, res, next) { config.searchEnabled = plugins.hasListeners('filter:search.query'); if (!req.user) { - if (res.locals.isAPI) { - res.status(200).json(config); - } else { - next(null, config); - } - return; + return filterConfig(); } user.getSettings(req.user.uid, function(err, settings) { @@ -86,15 +91,8 @@ apiController.getConfig = function(req, res, next) { config.categoryTopicSort = settings.categoryTopicSort || config.categoryTopicSort; config.topicSearchEnabled = settings.topicSearchEnabled || false; - plugins.fireHook('filter:config.get', config, function(err, config) { - if (res.locals.isAPI) { - res.status(200).json(config); - } else { - next(err, config); - } - }); + filterConfig(); }); - };