From aae68065221e1087aea2627a3a265be4e9f42867 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Tue, 22 Sep 2015 17:17:48 -0300 Subject: [PATCH] Replace all Settings --- .../saml_rocketchat.coffee | 22 ++++---- packages/rocketchat-ldap/config_server.coffee | 4 +- packages/rocketchat-ldap/package.js | 5 +- packages/rocketchat-lib/package.js | 36 +++++++------ .../settings/lib/settings.coffee | 5 +- .../settings/server/addOAuthService.coffee | 20 +++---- .../settings/server/methods.coffee | 31 ++++++++--- .../settings/server/models/Settings.coffee | 54 +++++++++++++++++++ .../settings/server/publication.coffee | 4 +- .../settings/server/startup.coffee | 6 ++- .../settings/server/updateServices.coffee | 22 ++++---- .../server/functions/get.coffee | 2 +- server/startup/initialData.coffee | 5 -- server/startup/migrations/v14.coffee | 32 +++++------ server/startup/migrations/v18.coffee | 8 +-- server/startup/migrations/v8.coffee | 18 +++---- 16 files changed, 176 insertions(+), 98 deletions(-) create mode 100644 packages/rocketchat-lib/settings/server/models/Settings.coffee diff --git a/packages/meteor-accounts-saml/saml_rocketchat.coffee b/packages/meteor-accounts-saml/saml_rocketchat.coffee index 25bd2c3e59fe..c75bddf38d9c 100644 --- a/packages/meteor-accounts-saml/saml_rocketchat.coffee +++ b/packages/meteor-accounts-saml/saml_rocketchat.coffee @@ -16,7 +16,7 @@ updateServices = -> Meteor.clearTimeout timer if timer? timer = Meteor.setTimeout -> - services = Settings.find({_id: /^(SAML_Custom_)[a-z]+$/i}).fetch() + services = RocketChat.models.Settings.find({_id: /^(SAML_Custom_)[a-z]+$/i}).fetch() Accounts.saml.settings.providers = [] @@ -27,26 +27,26 @@ updateServices = -> if service.value is true data = - buttonLabelText: Settings.findOne({_id: "#{service._id}_button_label_text"})?.value - buttonLabelColor: Settings.findOne({_id: "#{service._id}_button_label_color"})?.value - buttonColor: Settings.findOne({_id: "#{service._id}_button_color"})?.value + buttonLabelText: RocketChat.models.Settings.findOneById("#{service._id}_button_label_text")?.value + buttonLabelColor: RocketChat.models.Settings.findOneById("#{service._id}_button_label_color")?.value + buttonColor: RocketChat.models.Settings.findOneById("#{service._id}_button_color")?.value clientConfig: - provider: Settings.findOne({_id: "#{service._id}_provider"})?.value + provider: RocketChat.models.Settings.findOneById("#{service._id}_provider")?.value - Accounts.saml.settings.generateUsername = Settings.findOne({_id: "#{service._id}_generate_username"})?.value + Accounts.saml.settings.generateUsername = RocketChat.models.Settings.findOneById("#{service._id}_generate_username")?.value Accounts.saml.settings.providers.push provider: data.clientConfig.provider - entryPoint: Settings.findOne({_id: "#{service._id}_entry_point"})?.value - issuer: Settings.findOne({_id: "#{service._id}_issuer"})?.value - cert: Settings.findOne({_id: "#{service._id}_cert"})?.value + entryPoint: RocketChat.models.Settings.findOneById("#{service._id}_entry_point")?.value + issuer: RocketChat.models.Settings.findOneById("#{service._id}_issuer")?.value + cert: RocketChat.models.Settings.findOneById("#{service._id}_cert")?.value ServiceConfiguration.configurations.upsert {service: serviceName.toLowerCase()}, $set: data else ServiceConfiguration.configurations.remove {service: serviceName.toLowerCase()} , 2000 -Settings.find().observe +RocketChat.models.Settings.find().observe added: (record) -> if /^SAML_.+/.test record._id updateServices() @@ -60,5 +60,5 @@ Settings.find().observe updateServices() Meteor.startup -> - if not Settings.findOne({_id: /^(SAML_Custom)[a-z]+$/i})? + if not RocketChat.models.Settings.findOne({_id: /^(SAML_Custom)[a-z]+$/i})? Meteor.call 'addSamlService', 'default' diff --git a/packages/rocketchat-ldap/config_server.coffee b/packages/rocketchat-ldap/config_server.coffee index 97d28976f210..93c569f61e37 100644 --- a/packages/rocketchat-ldap/config_server.coffee +++ b/packages/rocketchat-ldap/config_server.coffee @@ -14,7 +14,7 @@ updateServices = -> Meteor.clearTimeout timer if timer? timer = Meteor.setTimeout -> - enable = Settings.findOne({_id: 'LDAP_Enable', value: true}) + enable = RocketChat.models.Settings.findOne({_id: 'LDAP_Enable', value: true}) if enable? console.log "Enabling LDAP".blue @@ -29,7 +29,7 @@ updateServices = -> LDAP_DEFAULTS.bindSearch = undefined , 2000 -Settings.find().observe +RocketChat.models.Settings.find().observe added: (record) -> if /^LDAP_.+/.test record._id updateServices() diff --git a/packages/rocketchat-ldap/package.js b/packages/rocketchat-ldap/package.js index 0d510d5fdff0..83d74fcf59f2 100644 --- a/packages/rocketchat-ldap/package.js +++ b/packages/rocketchat-ldap/package.js @@ -6,7 +6,7 @@ Package.describe({ }); Npm.depends({ - ldapjs: "0.7.1", + ldapjs: "0.7.1", }); // Loads all i18n.json files into tapi18nFiles @@ -22,6 +22,7 @@ Package.onUse(function(api) { api.versionsFrom('1.0.3.1'); // Commom + api.use('rocketchat:lib@0.0.1'); api.use('tap:i18n@1.5.1'); api.use('yasaricli:slugify'); api.use('coffeescript'); @@ -43,7 +44,7 @@ Package.onUse(function(api) { api.addFiles('config_server.coffee', 'server'); api.addFiles(tapi18nFiles); - + api.export('LDAP', 'server'); api.export('LDAP_DEFAULTS', 'server'); api.export('MeteorWrapperLdapjs'); diff --git a/packages/rocketchat-lib/package.js b/packages/rocketchat-lib/package.js index dd86ea6ab0cf..71da41c68a13 100644 --- a/packages/rocketchat-lib/package.js +++ b/packages/rocketchat-lib/package.js @@ -15,6 +15,7 @@ Package.onUse(function(api) { api.use('check'); api.use('underscore'); api.use('underscorestring:underscore.string'); + api.use('monbro:mongodb-mapreduce-aggregation@1.0.1'); // TAPi18n api.use('templating', 'client'); @@ -29,14 +30,33 @@ Package.onUse(function(api) { api.imply('tap:i18n'); api.addFiles("package-tap.i18n", ["client", "server"]); + // COMMON api.addFiles('lib/core.coffee'); api.addFiles('lib/callbacks.coffee'); api.addFiles('lib/slashCommand.coffee'); - api.addFiles('settings/lib/settings.coffee'); + // MODELS SERVER + api.addFiles('server/models/_Base.coffee', 'server'); + api.addFiles('server/models/Users.coffee', 'server'); + api.addFiles('server/models/Subscriptions.coffee', 'server'); + api.addFiles('server/models/Rooms.coffee', 'server'); + api.addFiles('server/models/Messages.coffee', 'server'); + api.addFiles('server/models/Reports.coffee', 'server'); + + // Settings api.addFiles('settings/lib/rocketchat.coffee'); + api.addFiles('settings/server/models/Settings.coffee', 'server'); + api.addFiles('settings/server/methods.coffee', 'server'); + api.addFiles('settings/server/publication.coffee', 'server'); + api.addFiles('settings/server/startup.coffee', 'server'); + api.addFiles('settings/server/updateServices.coffee', 'server'); + api.addFiles('settings/server/addOAuthService.coffee', 'server'); + + api.addFiles('settings/lib/settings.coffee'); + + // CLIENT api.addFiles('client/Notifications.coffee', 'client'); api.addFiles('client/TabBar.coffee', 'client'); @@ -59,22 +79,8 @@ Package.onUse(function(api) { api.addFiles('server/Notifications.coffee', 'server'); - // Settings - api.addFiles('settings/server/methods.coffee', 'server'); - api.addFiles('settings/server/publication.coffee', 'server'); - api.addFiles('settings/server/startup.coffee', 'server'); - api.addFiles('settings/server/updateServices.coffee', 'server'); - api.addFiles('settings/server/addOAuthService.coffee', 'server'); - api.addFiles('server/cdn.coffee', 'server'); - api.addFiles('server/models/_Base.coffee', 'server'); - api.addFiles('server/models/Users.coffee', 'server'); - api.addFiles('server/models/Subscriptions.coffee', 'server'); - api.addFiles('server/models/Rooms.coffee', 'server'); - api.addFiles('server/models/Messages.coffee', 'server'); - api.addFiles('server/models/Reports.coffee', 'server'); - // TAPi18n -- needs to be added last api.addFiles(tapi18nFiles, ["client", "server"]); diff --git a/packages/rocketchat-lib/settings/lib/settings.coffee b/packages/rocketchat-lib/settings/lib/settings.coffee index 7fca2088cb07..cc97e7623a29 100644 --- a/packages/rocketchat-lib/settings/lib/settings.coffee +++ b/packages/rocketchat-lib/settings/lib/settings.coffee @@ -1,4 +1,7 @@ -@Settings = new Meteor.Collection 'rocketchat_settings' +if Meteor.isClient is true + @Settings = Settings = new Meteor.Collection 'rocketchat_settings' +else + Settings = RocketChat.models.Settings Settings.find().observe added: (record) -> diff --git a/packages/rocketchat-lib/settings/server/addOAuthService.coffee b/packages/rocketchat-lib/settings/server/addOAuthService.coffee index 479877939ac4..fb95f2e4d517 100644 --- a/packages/rocketchat-lib/settings/server/addOAuthService.coffee +++ b/packages/rocketchat-lib/settings/server/addOAuthService.coffee @@ -30,13 +30,13 @@ Meteor.methods throw new Meteor.Error 'not-authorized', '[methods] addOAuthService -> Not authorized' name = s.capitalize(name) - Settings.remove _id: "Accounts_OAuth_Custom_#{name}" - Settings.remove _id: "Accounts_OAuth_Custom_#{name}_url" - Settings.remove _id: "Accounts_OAuth_Custom_#{name}_token_path" - Settings.remove _id: "Accounts_OAuth_Custom_#{name}_identity_path" - Settings.remove _id: "Accounts_OAuth_Custom_#{name}_authorize_path" - Settings.remove _id: "Accounts_OAuth_Custom_#{name}_id" - Settings.remove _id: "Accounts_OAuth_Custom_#{name}_secret" - Settings.remove _id: "Accounts_OAuth_Custom_#{name}_button_label_text" - Settings.remove _id: "Accounts_OAuth_Custom_#{name}_button_label_color" - Settings.remove _id: "Accounts_OAuth_Custom_#{name}_button_color" + RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}" + RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_url" + RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_token_path" + RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_identity_path" + RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_authorize_path" + RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_id" + RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_secret" + RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_button_label_text" + RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_button_label_color" + RocketChat.settings.removeById "Accounts_OAuth_Custom_#{name}_button_color" diff --git a/packages/rocketchat-lib/settings/server/methods.coffee b/packages/rocketchat-lib/settings/server/methods.coffee index cf19272c96b4..deac2a9bac5f 100644 --- a/packages/rocketchat-lib/settings/server/methods.coffee +++ b/packages/rocketchat-lib/settings/server/methods.coffee @@ -1,5 +1,5 @@ ### -# Add a setting +# Add a setting # @param {String} _id # @param {Mixed} value # @param {Object} setting @@ -24,7 +24,7 @@ RocketChat.settings.add = (_id, value, options = {}) -> updateSettings.section = options.section if options.section updateSettings.public = options.public if options.public - return Settings.upsert { _id: _id }, { $setOnInsert: { value: value }, $set: updateSettings } + return RocketChat.models.Settings.upsert { _id: _id }, { $setOnInsert: { value: value }, $set: updateSettings } ### # Add a setting group @@ -37,22 +37,37 @@ RocketChat.settings.addGroup = (_id, options = {}) -> # console.log '[functions] RocketChat.settings.addGroup -> '.green, 'arguments:', arguments - updateSettings = + updateSettings = i18nLabel: options.i18nLabel or _id i18nDescription: options.i18nDescription if options.i18nDescription? type: 'group' - - return Settings.upsert { _id: _id }, { $set: updateSettings } + + return RocketChat.models.Settings.upsert { _id: _id }, { $set: updateSettings } + + +### +# Remove a setting by id +# @param {String} _id +### + +RocketChat.settings.removeById = (_id) -> + if not _id + return false + + # console.log '[functions] RocketChat.settings.add -> '.green, 'arguments:', arguments + + return RocketChat.models.Settings.removeById _id + Meteor.methods saveSetting: (_id, value) -> console.log '[method] saveSetting', _id, value if Meteor.userId()? user = Meteor.users.findOne Meteor.userId() - + unless RocketChat.authz.hasPermission(Meteor.userId(), 'edit-privileged-setting') is true throw new Meteor.Error 503, 'Not authorized' # console.log "saveSetting -> ".green, _id, value - Settings.update { _id: _id }, { $set: { value: value } } - return true \ No newline at end of file + RocketChat.models.Settings.updateValueById _id, value + return true diff --git a/packages/rocketchat-lib/settings/server/models/Settings.coffee b/packages/rocketchat-lib/settings/server/models/Settings.coffee new file mode 100644 index 000000000000..282c9262b6b8 --- /dev/null +++ b/packages/rocketchat-lib/settings/server/models/Settings.coffee @@ -0,0 +1,54 @@ +RocketChat.models.Settings = new class extends RocketChat.models._Base + constructor: -> + @_initModel 'settings' + + + # FIND ONE + findOneById: (_id, options) -> + query = + _id: _id + + return @findOne query, options + + + # FIND + findByRole: (role, options) -> + query = + role: role + + return @find query, options + + findPublic: (options) -> + query = + public: true + + return @find query, options + + + # UPDATE + updateValueById: (_id, value) -> + query = + _id: _id + + update = + $set: + value: value + + return @update query, update + + + # REMOVE + createWithIdAndValue: (_id, value) -> + record = + _id: _id + value: value + + return @insert record + + + # REMOVE + removeById: (_id) -> + query = + _id: _id + + return @remove query diff --git a/packages/rocketchat-lib/settings/server/publication.coffee b/packages/rocketchat-lib/settings/server/publication.coffee index 92dab9b981ac..05cff8a27663 100644 --- a/packages/rocketchat-lib/settings/server/publication.coffee +++ b/packages/rocketchat-lib/settings/server/publication.coffee @@ -1,6 +1,6 @@ Meteor.publish 'settings', -> console.log '[publish] settings'.green - return Settings.find { public: true }, { fields: _id: 1, value: 1 } + return RocketChat.models.Settings.findPublic { fields: _id: 1, value: 1 } Meteor.publish 'admin-settings', -> console.log '[publish] admin-settings'.green @@ -9,7 +9,7 @@ Meteor.publish 'admin-settings', -> return @ready() if RocketChat.authz.hasPermission( @userId, 'view-privileged-setting') - return Settings.find() + return RocketChat.models.Settings.find() else return @ready() diff --git a/packages/rocketchat-lib/settings/server/startup.coffee b/packages/rocketchat-lib/settings/server/startup.coffee index 8344d52cfe6e..bc87a272a9da 100644 --- a/packages/rocketchat-lib/settings/server/startup.coffee +++ b/packages/rocketchat-lib/settings/server/startup.coffee @@ -1,4 +1,8 @@ Meteor.startup -> + # Insert server unique id if it doesn't exist + if not RocketChat.models.Settings.findOneById 'uniqueID' + RocketChat.models.Settings.createWithIdAndValue 'uniqueID', Random.id() + RocketChat.settings.addGroup 'Accounts' RocketChat.settings.add 'Accounts_RegistrationRequired', true, { type: 'boolean', group: 'Accounts', public: true, section: 'Registration' } RocketChat.settings.add 'Accounts_EmailVerification', false, { type: 'boolean', group: 'Accounts', public: true, section: 'Registration' } @@ -45,7 +49,7 @@ Meteor.startup -> RocketChat.settings.add 'SMTP_Username', '', { type: 'string', group: 'SMTP' } RocketChat.settings.add 'SMTP_Password', '', { type: 'string', group: 'SMTP' } RocketChat.settings.add 'From_Email', 'no-reply@rocket.chat', { type: 'string', group: 'SMTP' } - + RocketChat.settings.add 'Invitation_Subject', 'You have been invited to Rocket.Chat', { type: 'string', group: 'SMTP', section: 'Invitation' } RocketChat.settings.add 'Invitation_HTML', '

You have been invited to

Rocket.Chat

Go to https://demo.rocket.chat and try the best open source chat solution available today!

', { type: 'string', multiline: true, group: 'SMTP', section: 'Invitation' } diff --git a/packages/rocketchat-lib/settings/server/updateServices.coffee b/packages/rocketchat-lib/settings/server/updateServices.coffee index 42c0098b7aa5..109a1363f583 100644 --- a/packages/rocketchat-lib/settings/server/updateServices.coffee +++ b/packages/rocketchat-lib/settings/server/updateServices.coffee @@ -3,7 +3,7 @@ updateServices = -> Meteor.clearTimeout timer if timer? timer = Meteor.setTimeout -> - services = Settings.find({_id: /^(Accounts_OAuth_|Accounts_OAuth_Custom_)[a-z]+$/i}).fetch() + services = RocketChat.models.Settings.find({_id: /^(Accounts_OAuth_|Accounts_OAuth_Custom_)[a-z]+$/i}).fetch() for service in services console.log "Updating login service #{service._id}".blue @@ -18,18 +18,18 @@ updateServices = -> if service.value is true data = - clientId: Settings.findOne({_id: "#{service._id}_id"})?.value - secret: Settings.findOne({_id: "#{service._id}_secret"})?.value + clientId: RocketChat.models.Settings.findOneById("#{service._id}_id")?.value + secret: RocketChat.models.Settings.findOneById("#{service._id}_secret")?.value if /Accounts_OAuth_Custom_/.test service._id data.custom = true - data.serverURL = Settings.findOne({_id: "#{service._id}_url"})?.value - data.tokenPath = Settings.findOne({_id: "#{service._id}_token_path"})?.value - data.identityPath = Settings.findOne({_id: "#{service._id}_identity_path"})?.value - data.authorizePath = Settings.findOne({_id: "#{service._id}_authorize_path"})?.value - data.buttonLabelText = Settings.findOne({_id: "#{service._id}_button_label_text"})?.value - data.buttonLabelColor = Settings.findOne({_id: "#{service._id}_button_label_color"})?.value - data.buttonColor = Settings.findOne({_id: "#{service._id}_button_color"})?.value + data.serverURL = RocketChat.models.Settings.findOneById("#{service._id}_url")?.value + data.tokenPath = RocketChat.models.Settings.findOneById("#{service._id}_token_path")?.value + data.identityPath = RocketChat.models.Settings.findOneById("#{service._id}_identity_path")?.value + data.authorizePath = RocketChat.models.Settings.findOneById("#{service._id}_authorize_path")?.value + data.buttonLabelText = RocketChat.models.Settings.findOneById("#{service._id}_button_label_text")?.value + data.buttonLabelColor = RocketChat.models.Settings.findOneById("#{service._id}_button_label_color")?.value + data.buttonColor = RocketChat.models.Settings.findOneById("#{service._id}_button_color")?.value new CustomOAuth serviceName.toLowerCase(), serverURL: data.serverURL tokenPath: data.tokenPath @@ -49,7 +49,7 @@ updateServices = -> ServiceConfiguration.configurations.remove {service: serviceName.toLowerCase()} , 2000 -Settings.find().observe +RocketChat.models.Settings.find().observe added: (record) -> if /^Accounts_OAuth_.+/.test record._id updateServices() diff --git a/packages/rocketchat-statistics/server/functions/get.coffee b/packages/rocketchat-statistics/server/functions/get.coffee index 6482c7186556..378e4b1943fd 100644 --- a/packages/rocketchat-statistics/server/functions/get.coffee +++ b/packages/rocketchat-statistics/server/functions/get.coffee @@ -2,7 +2,7 @@ RocketChat.statistics.get = -> statistics = {} # Version - statistics.uniqueId = Settings.findOne({ _id: "uniqueID" })?.value + statistics.uniqueId = RocketChat.settings.get("uniqueID") statistics.version = BuildInfo?.commit?.hash statistics.versionDate = BuildInfo?.commit?.date diff --git a/server/startup/initialData.coffee b/server/startup/initialData.coffee index 169f74b6ba8b..567fb3af3eca 100644 --- a/server/startup/initialData.coffee +++ b/server/startup/initialData.coffee @@ -1,10 +1,5 @@ Meteor.startup -> Meteor.defer -> - # Insert server unique id if it doesn't exist - if not Settings.findOne { _id: 'uniqueID' } - Settings.insert - _id: 'uniqueID' - value: Random.id() if not RocketChat.models.Rooms.findOneByName('general')? RocketChat.models.Rooms.createWithIdTypeAndName 'GENERAL', 'c', 'general', diff --git a/server/startup/migrations/v14.coffee b/server/startup/migrations/v14.coffee index 99549a4a12ed..2ac5724be84a 100644 --- a/server/startup/migrations/v14.coffee +++ b/server/startup/migrations/v14.coffee @@ -3,17 +3,17 @@ Meteor.startup -> version: 14 up: -> # Remove unused settings - Settings.remove { _id: "API_Piwik_URL" } - Settings.remove { _id: "API_Piwik_ID" } - - Settings.remove { _id: "Message_Edit" } - Settings.remove { _id: "Message_Delete" } - Settings.remove { _id: "Message_KeepStatusHistory" } - - Settings.update { _id: "Message_ShowEditedStatus" }, { $set: { type: "boolean", value: true } } - Settings.update { _id: "Message_ShowDeletedStatus" }, { $set: { type: "boolean", value: false } } + RocketChat.models.Settings.remove { _id: "API_Piwik_URL" } + RocketChat.models.Settings.remove { _id: "API_Piwik_ID" } - metaKeys = [ + RocketChat.models.Settings.remove { _id: "Message_Edit" } + RocketChat.models.Settings.remove { _id: "Message_Delete" } + RocketChat.models.Settings.remove { _id: "Message_KeepStatusHistory" } + + RocketChat.models.Settings.update { _id: "Message_ShowEditedStatus" }, { $set: { type: "boolean", value: true } } + RocketChat.models.Settings.update { _id: "Message_ShowDeletedStatus" }, { $set: { type: "boolean", value: false } } + + metaKeys = [ 'old': 'Meta:language' 'new': 'Meta_language' , @@ -31,12 +31,12 @@ Meteor.startup -> ] for oldAndNew in metaKeys - oldValue = Settings.findOne({_id: oldAndNew.old})?.value - newValue = Settings.findOne({_id: oldAndNew.new})?.value + oldValue = RocketChat.models.Settings.findOne({_id: oldAndNew.old})?.value + newValue = RocketChat.models.Settings.findOne({_id: oldAndNew.new})?.value if oldValue? and not newValue? - Settings.update { _id: oldAndNew.new }, { $set: { value: newValue } } - - Settings.remove { _id: oldAndNew.old } + RocketChat.models.Settings.update { _id: oldAndNew.new }, { $set: { value: newValue } } + + RocketChat.models.Settings.remove { _id: oldAndNew.old } - Settings.remove { _id: "SMTP_Security" } + RocketChat.models.Settings.remove { _id: "SMTP_Security" } diff --git a/server/startup/migrations/v18.coffee b/server/startup/migrations/v18.coffee index afddbdd631d1..f9293c59bfaa 100644 --- a/server/startup/migrations/v18.coffee +++ b/server/startup/migrations/v18.coffee @@ -26,10 +26,10 @@ Meteor.startup -> Accounts_Twitter_secret: 'Accounts_OAuth_Twitter_secret' for from, to of changes - record = Settings.findOne _id: from + record = RocketChat.models.Settings.findOne _id: from if record? delete record._id - Settings.upsert {_id: to}, record - Settings.remove _id: from + RocketChat.models.Settings.upsert {_id: to}, record + RocketChat.models.Settings.remove _id: from - ServiceConfiguration.configurations.remove({}) \ No newline at end of file + ServiceConfiguration.configurations.remove({}) diff --git a/server/startup/migrations/v8.coffee b/server/startup/migrations/v8.coffee index 637e3f9a7ff1..87d210f5ad98 100644 --- a/server/startup/migrations/v8.coffee +++ b/server/startup/migrations/v8.coffee @@ -3,13 +3,13 @@ Meteor.startup -> version: 8 up: -> console.log 'Load old settings record' - settings = Settings.findOne({ _id: 'settings' }) + settings = RocketChat.models.Settings.findOne({ _id: 'settings' }) if settings - Settings.insert { _id: 'CDN_PREFIX', value: settings.CDN_PREFIX, type: 'string', group: 'General' } if settings.CDN_PREFIX? - Settings.insert { _id: 'MAIL_URL', value: settings.ENV.MAIL_URL, type: 'string', group: 'SMTP' } if settings.ENV?.MAIL_URL? - Settings.insert { _id: 'Accounts_denyUnverifiedEmails', value: settings.denyUnverifiedEmails, type: 'boolean', group: 'Accounts' } if settings.denyUnverifiedEmails? - Settings.insert { _id: 'KADIRA_APP_ID', value: settings.kadira.appId, type: 'string', group: 'API' } if settings.kadira?.appId? - Settings.insert { _id: 'KADIRA_APP_SECRET', value: settings.kadira.appSecret, type: 'string', group: 'API' } if settings.kadira?.appSecret? - Settings.insert { _id: 'avatarStore_type', value: settings.public.avatarStore.type, type: 'string', group: 'API' } if settings.public?.avatarStore?.type? - Settings.insert { _id: 'avatarStore_path', value: settings.public.avatarStore.path, type: 'string', group: 'API' } if settings.public?.avatarStore?.path? - Settings.remove { _id: 'settings' } \ No newline at end of file + RocketChat.models.Settings.insert { _id: 'CDN_PREFIX', value: settings.CDN_PREFIX, type: 'string', group: 'General' } if settings.CDN_PREFIX? + RocketChat.models.Settings.insert { _id: 'MAIL_URL', value: settings.ENV.MAIL_URL, type: 'string', group: 'SMTP' } if settings.ENV?.MAIL_URL? + RocketChat.models.Settings.insert { _id: 'Accounts_denyUnverifiedEmails', value: settings.denyUnverifiedEmails, type: 'boolean', group: 'Accounts' } if settings.denyUnverifiedEmails? + RocketChat.models.Settings.insert { _id: 'KADIRA_APP_ID', value: settings.kadira.appId, type: 'string', group: 'API' } if settings.kadira?.appId? + RocketChat.models.Settings.insert { _id: 'KADIRA_APP_SECRET', value: settings.kadira.appSecret, type: 'string', group: 'API' } if settings.kadira?.appSecret? + RocketChat.models.Settings.insert { _id: 'avatarStore_type', value: settings.public.avatarStore.type, type: 'string', group: 'API' } if settings.public?.avatarStore?.type? + RocketChat.models.Settings.insert { _id: 'avatarStore_path', value: settings.public.avatarStore.path, type: 'string', group: 'API' } if settings.public?.avatarStore?.path? + RocketChat.models.Settings.remove { _id: 'settings' }