Overwrite settings on insert via settings.json file; Keep settings in local variable for avoiding unnecessary finds (less computations)
parent
d739dadebf
commit
784c37a901
@ -0,0 +1,8 @@ |
||||
### |
||||
# RocketChat.settings holds all packages settings |
||||
# @namespace RocketChat.settings |
||||
### |
||||
RocketChat.settings = {} |
||||
|
||||
RocketChat.settings.get = (_id) -> |
||||
return Meteor.settings?[_id] |
@ -1,10 +1,41 @@ |
||||
### |
||||
# RocketChat.settings holds all packages settings |
||||
# @namespace RocketChat.settings |
||||
### |
||||
@Settings = new Meteor.Collection 'settings' |
||||
|
||||
RocketChat.settings = {} |
||||
Settings.find().observe |
||||
added: (record) -> |
||||
Meteor.settings ?= {} |
||||
Meteor.settings[record._id] = record |
||||
# configLoginServices settings |
||||
# loadEnvConfigs settings |
||||
# configCDN settings |
||||
# configKadira settings |
||||
|
||||
RocketChat.settings.get = (_id) -> |
||||
return Settings.findOne(_id) |
||||
changed: (record) -> |
||||
Meteor.settings?[record._id] = record |
||||
# __meteor_runtime_config__?.PUBLIC_SETTINGS = Meteor.settings?.public |
||||
# configLoginServices settings |
||||
# loadEnvConfigs settings |
||||
# configCDN settings |
||||
# configKadira settings |
||||
|
||||
removed: (record) -> |
||||
delete Meteor.settings?[record._id] |
||||
|
||||
# loadEnvConfigs = (settings) -> |
||||
# if settings.ENV? |
||||
# for key, value of settings.ENV |
||||
# process.env[key] = value |
||||
|
||||
# configLoginServices = (settings) -> |
||||
# settings?['login-services']?.forEach (config) -> |
||||
# ServiceConfiguration.configurations.remove |
||||
# service: config.service |
||||
|
||||
# ServiceConfiguration.configurations.insert config |
||||
|
||||
# configCDN = (settings) -> |
||||
# if settings.CDN_PREFIX? |
||||
# WebAppInternals.setBundledJsCssPrefix settings.CDN_PREFIX |
||||
|
||||
# configKadira = (settings) -> |
||||
# if settings.kadira? |
||||
# Kadira.connect(settings.kadira.appId, settings.kadira.appSecret) |
@ -1,38 +0,0 @@ |
||||
# @Settings = new Meteor.Collection 'settings' |
||||
|
||||
loadEnvConfigs = (settings) -> |
||||
if settings.ENV? |
||||
for key, value of settings.ENV |
||||
process.env[key] = value |
||||
|
||||
configLoginServices = (settings) -> |
||||
settings?['login-services']?.forEach (config) -> |
||||
ServiceConfiguration.configurations.remove |
||||
service: config.service |
||||
|
||||
ServiceConfiguration.configurations.insert config |
||||
|
||||
configCDN = (settings) -> |
||||
if settings.CDN_PREFIX? |
||||
WebAppInternals.setBundledJsCssPrefix settings.CDN_PREFIX |
||||
|
||||
configKadira = (settings) -> |
||||
if settings.kadira? |
||||
Kadira.connect(settings.kadira.appId, settings.kadira.appSecret) |
||||
|
||||
Settings.find({_id: 'settings'}).observe |
||||
added: (settings) -> |
||||
Meteor.settings = settings |
||||
__meteor_runtime_config__?.PUBLIC_SETTINGS = Meteor.settings?.public |
||||
configLoginServices settings |
||||
loadEnvConfigs settings |
||||
configCDN settings |
||||
configKadira settings |
||||
|
||||
changed: (settings) -> |
||||
Meteor.settings = settings |
||||
__meteor_runtime_config__?.PUBLIC_SETTINGS = Meteor.settings?.public |
||||
configLoginServices settings |
||||
loadEnvConfigs settings |
||||
configCDN settings |
||||
configKadira settings |
Loading…
Reference in new issue