Skip to content
Snippets Groups Projects
Commit 7ba66cde authored by Gabriel Engel's avatar Gabriel Engel
Browse files

split server and client settings initial loading logic

parent 91e9f16b
No related branches found
Tags 6.10.0-rc.7
No related merge requests found
if Meteor.isClient is true
@Settings = Settings = new Meteor.Collection 'rocketchat_settings'
else
Settings = RocketChat.models.Settings
@Settings = Settings = new Meteor.Collection 'rocketchat_settings'
initialLoad = true
Meteor.settings ?= {}
process?.env ?= {}
Settings.find().observe
added: (record) ->
Meteor.settings[record._id] = record.value
process?.env[record._id] = record.value
RocketChat.settings.load record._id, record.value, initialLoad
changed: (record) ->
Meteor.settings?[record._id] = record.value
process?.env[record._id] = record.value
Meteor.settings[record._id] = record.value
RocketChat.settings.load record._id, record.value, initialLoad
removed: (record) ->
delete Meteor.settings?[record._id]
delete process?.env?[record._id]
delete Meteor.settings[record._id]
RocketChat.settings.load record._id, undefined, initialLoad
initialLoad = false
......@@ -113,12 +113,31 @@ RocketChat.settings.add 'Layout_Login_Terms', 'By proceeding to create your acco
RocketChat.settings.add 'Statistics_opt_out', false, { type: 'boolean', group: false }
initialLoad = true
RocketChat.models.Settings.find().observe
added: (record) ->
Meteor.settings[record._id] = record.value
process.env[record._id] = record.value
RocketChat.settings.load record._id, record.value, initialLoad
changed: (record) ->
Meteor.settings[record._id] = record.value
process.env[record._id] = record.value
RocketChat.settings.load record._id, record.value, initialLoad
removed: (record) ->
delete Meteor.settings[record._id]
delete process.env[record._id]
RocketChat.settings.load record._id, undefined, initialLoad
initialLoad = false
Meteor.startup ->
if process?.env? and not process.env['MAIL_URL']? and RocketChat.settings.get('SMTP_Host') and RocketChat.settings.get('SMTP_Username') and RocketChat.settings.get('SMTP_Password')
process.env['MAIL_URL'] = "smtp://" + encodeURIComponent(RocketChat.settings.get('SMTP_Username')) + ':' + encodeURIComponent(RocketChat.settings.get('SMTP_Password')) + '@' + encodeURIComponent(RocketChat.settings.get('SMTP_Host'))
if RocketChat.settings.get('SMTP_Port')
process.env['MAIL_URL'] += ':' + parseInt(RocketChat.settings.get('SMTP_Port'))
# Remove runtime settings (non-persistent)
Meteor.startup ->
RocketChat.models.Settings.update({ ts: { $lt: RocketChat.settings.ts }, persistent: false }, { $set: { hidden: true } })
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment