jiti-meet/modules/config/Util.js

55 lines
2.1 KiB
JavaScript
Raw Normal View History

2016-11-11 15:00:54 +00:00
const logger = require("jitsi-meet-logger").getLogger(__filename);
var ConfigUtil = {
/**
* Method overrides JSON properties in <tt>config</tt> and
* <tt>interfaceConfig</tt> Objects with the values from <tt>newConfig</tt>
* @param config the config object for which we'll be overriding properties
* @param interfaceConfig the interfaceConfig object for which we'll be
* overriding properties.
2016-11-21 21:08:39 +00:00
* @param loggingConfig the logging config object for which we'll be
* overriding properties.
* @param newConfig object containing configuration properties. Destination
* object is selected based on root property name:
* {
* config: {
* // config.js properties to be
* },
* interfaceConfig: {
2016-11-21 21:08:39 +00:00
* // interface_config.js properties here
* },
* loggingConfig: {
* // logging_config.js properties here
* }
* }
*/
2016-11-21 21:08:39 +00:00
overrideConfigJSON: function (config,
interfaceConfig, loggingConfig, newConfig) {
var configRoot, key, value, confObj;
for (configRoot in newConfig) {
confObj = null;
if (configRoot == "config") {
confObj = config;
} else if (configRoot == "interfaceConfig") {
confObj = interfaceConfig;
2016-11-21 21:08:39 +00:00
} else if (configRoot == "loggingConfig") {
confObj = loggingConfig;
} else {
continue;
}
for (key in newConfig[configRoot]) {
value = newConfig[configRoot][key];
if (confObj[key] && typeof confObj[key] !== typeof value) {
2016-11-11 15:00:54 +00:00
logger.log("Overriding a " + configRoot +
" property with a property of different type.");
}
2016-11-11 15:00:54 +00:00
logger.info("Overriding " + key + " with: " + value);
confObj[key] = value;
}
}
}
};
module.exports = ConfigUtil;