Skip to content

Node.js based forum software built for the modern web

fire filter:config.get even if anonymous

psychobunny5b67cd841e5c
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();
});
-
};