diff --git a/packages/rocketchat-api/server/v1/settings.js b/packages/rocketchat-api/server/v1/settings.js index 3662ba1485303..25975fd998d14 100644 --- a/packages/rocketchat-api/server/v1/settings.js +++ b/packages/rocketchat-api/server/v1/settings.js @@ -73,10 +73,23 @@ RocketChat.API.v1.addRoute('settings/:_id', { authRequired: true }, { return RocketChat.API.v1.unauthorized(); } + // allow special handling of particular setting types + const setting = RocketChat.models.Settings.findOneNotHiddenById(this.urlParams._id); + if (setting.type === 'action' && this.bodyParams && this.bodyParams.execute) { + //execute the configured method + Meteor.call(setting.value); + return RocketChat.API.v1.success(); + } + + if (setting.type === 'color' && this.bodyParams && this.bodyParams.editor && this.bodyParams.value) { + RocketChat.models.Settings.updateOptionsById(this.urlParams._id, { editor: this.bodyParams.editor }); + RocketChat.models.Settings.updateValueNotHiddenById(this.urlParams._id, this.bodyParams.value); + return RocketChat.API.v1.success(); + } + check(this.bodyParams, { value: Match.Any }); - if (RocketChat.models.Settings.updateValueNotHiddenById(this.urlParams._id, this.bodyParams.value)) { return RocketChat.API.v1.success(); } @@ -90,7 +103,7 @@ RocketChat.API.v1.addRoute('service.configurations', { authRequired: false }, { const ServiceConfiguration = Package['service-configuration'].ServiceConfiguration; return RocketChat.API.v1.success({ - configurations: ServiceConfiguration.configurations.find({}, {fields: {secret: 0}}).fetch() + configurations: ServiceConfiguration.configurations.find({}, { fields: { secret: 0 } }).fetch() }); } });