mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 02:55:58 +01:00 
			
		
		
		
	fire filter:config.get even if anonymous
This commit is contained in:
		| @@ -12,6 +12,16 @@ var pkg = require('./../../package.json'), | |||||||
| var apiController = {}; | var apiController = {}; | ||||||
|  |  | ||||||
| apiController.getConfig = function(req, res, next) { | 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 = {}; | 	var config = {}; | ||||||
| 	config.relative_path = nconf.get('relative_path'); | 	config.relative_path = nconf.get('relative_path'); | ||||||
| 	config.socketioTransports = nconf.get('socket.io:transports') || ['polling', 'websocket']; | 	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'); | 	config.searchEnabled = plugins.hasListeners('filter:search.query'); | ||||||
|  |  | ||||||
| 	if (!req.user) { | 	if (!req.user) { | ||||||
| 		if (res.locals.isAPI) { | 		return filterConfig(); | ||||||
| 			res.status(200).json(config); |  | ||||||
| 		} else { |  | ||||||
| 			next(null, config); |  | ||||||
| 		} |  | ||||||
| 		return; |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	user.getSettings(req.user.uid, function(err, settings) { | 	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.categoryTopicSort = settings.categoryTopicSort || config.categoryTopicSort; | ||||||
| 		config.topicSearchEnabled = settings.topicSearchEnabled || false; | 		config.topicSearchEnabled = settings.topicSearchEnabled || false; | ||||||
|  |  | ||||||
| 		plugins.fireHook('filter:config.get', config, function(err, config) { | 		filterConfig(); | ||||||
| 			if (res.locals.isAPI) { |  | ||||||
| 				res.status(200).json(config); |  | ||||||
| 			} else { |  | ||||||
| 				next(err, config); |  | ||||||
| 			} |  | ||||||
| 	}); | 	}); | ||||||
| 	}); |  | ||||||
|  |  | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user