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

re organising files

parent 3b368dce
No related branches found
No related tags found
No related merge requests found
......@@ -99,6 +99,5 @@ Package.onTest(function(api) {
api.use('coffeescript');
api.use('sanjo:jasmine@0.20.2');
api.use('rocketchat:lib');
api.addFiles('tests/jasmine/server/unit/models/_Base.spec.coffee', 'server');
api.addFiles('tests/jasmine/server/unit/models/_Base.spec.coffee', 'server');
});
......@@ -6,8 +6,9 @@
settingsDict = new ReactiveDict('settings')
RocketChat.settings.subscription = Meteor.subscribe 'settings'
RocketChat.settings.get = (_id) ->
return settingsDict.get(_id)
RocketChat.settings.onload '*', (key, value) ->
return settingsDict.set key, value
\ No newline at end of file
return settingsDict.set key, value
......@@ -4,29 +4,26 @@ else
Settings = RocketChat.models.Settings
initialLoad = true
Meteor.settings ?= {}
process?.env ?= {}
Settings.find().observe
added: (record) ->
Meteor.settings ?= {}
Meteor.settings[record._id] = record.value
process?.env[record._id] = record.value
RocketChat.settings.load record._id, record.value, initialLoad
if process?
process.env ?= {}
process.env[record._id] = record.value
changed: (record) ->
Meteor.settings?[record._id] = record.value
process?.env[record._id] = record.value
RocketChat.settings.load record._id, record.value, initialLoad
if process?
process.env[record._id] = record.value
removed: (record) ->
RocketChat.settings.load record._id, undefined, initialLoad
delete Meteor.settings?[record._id]
delete process?.env?[record._id]
RocketChat.settings.load record._id, undefined, initialLoad
initialLoad = false
......@@ -5,11 +5,11 @@
# @param {Object} setting
###
RocketChat.settings.add = (_id, value, options = {}) ->
# console.log '[functions] RocketChat.settings.add -> '.green, 'arguments:', arguments
if not _id or not value?
return false
# console.log '[functions] RocketChat.settings.add -> '.green, 'arguments:', arguments
options.packageValue = value
options.valueSource = 'packageValue'
......@@ -49,21 +49,23 @@ RocketChat.settings.add = (_id, value, options = {}) ->
# @param {String} _id
###
RocketChat.settings.addGroup = (_id, options = {}) ->
# console.log '[functions] RocketChat.settings.addGroup -> '.green, 'arguments:', arguments
if not _id
return false
# console.log '[functions] RocketChat.settings.addGroup -> '.green, 'arguments:', arguments
if not options.i18nLabel?
options.i18nLabel = _id
setting =
type: 'group'
i18nLabel: options.i18nLabel or _id
if not options.i18nDescription?
options.i18nDescription = "#{_id}_Description"
setting.i18nDescription = if options.i18nDescription?
options.i18nDescription
else
"#{_id}_Description"
upsertChanges =
$set: options
$setOnInsert:
type: 'group'
createdAt: new Date
upsertChanges = { $set: setting }
if options.persistent is true
upsertChanges.$unset = { ts: true }
else
......@@ -77,11 +79,11 @@ RocketChat.settings.addGroup = (_id, options = {}) ->
# @param {String} _id
###
RocketChat.settings.removeById = (_id) ->
# console.log '[functions] RocketChat.settings.add -> '.green, 'arguments:', arguments
if not _id
return false
# console.log '[functions] RocketChat.settings.add -> '.green, 'arguments:', arguments
return RocketChat.models.Settings.removeById _id
......@@ -90,7 +92,9 @@ RocketChat.settings.removeById = (_id) ->
# @param {String} _id
###
RocketChat.settings.updateById = (_id, value) ->
if not _id
# console.log '[functions] RocketChat.settings.updateById -> '.green, 'arguments:', arguments
if not _id or not value?
return false
return RocketChat.models.Settings.updateValueById _id, value
......
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