You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Util.js 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. const logger = require("jitsi-meet-logger").getLogger(__filename);
  2. var ConfigUtil = {
  3. /**
  4. * Method overrides JSON properties in <tt>config</tt> and
  5. * <tt>interfaceConfig</tt> Objects with the values from <tt>newConfig</tt>
  6. * @param config the config object for which we'll be overriding properties
  7. * @param interfaceConfig the interfaceConfig object for which we'll be
  8. * overriding properties.
  9. * @param loggingConfig the logging config object for which we'll be
  10. * overriding properties.
  11. * @param newConfig object containing configuration properties. Destination
  12. * object is selected based on root property name:
  13. * {
  14. * config: {
  15. * // config.js properties to be
  16. * },
  17. * interfaceConfig: {
  18. * // interface_config.js properties here
  19. * },
  20. * loggingConfig: {
  21. * // logging_config.js properties here
  22. * }
  23. * }
  24. */
  25. overrideConfigJSON: function (config,
  26. interfaceConfig, loggingConfig, newConfig) {
  27. var configRoot, key, value, confObj;
  28. for (configRoot in newConfig) {
  29. confObj = null;
  30. if (configRoot == "config") {
  31. confObj = config;
  32. } else if (configRoot == "interfaceConfig") {
  33. confObj = interfaceConfig;
  34. } else if (configRoot == "loggingConfig") {
  35. confObj = loggingConfig;
  36. } else {
  37. continue;
  38. }
  39. for (key in newConfig[configRoot]) {
  40. value = newConfig[configRoot][key];
  41. if (confObj[key] && typeof confObj[key] !== typeof value) {
  42. logger.log("Overriding a " + configRoot +
  43. " property with a property of different type.");
  44. }
  45. logger.info("Overriding " + key + " with: " + value);
  46. confObj[key] = value;
  47. }
  48. }
  49. }
  50. };
  51. module.exports = ConfigUtil;