[MM-11861] Design & implement a better way for plugins to update their own configuration (#9712)
* [MM-11861] Design & implement a better way for plugins to update their own configuration Added GetPluginConfig and SavePluginConfig plugin APIs. Added test cases for testing new APIs. * Fixed gofmt error * Minor changes requested in PR
Этот коммит содержится в:
коммит произвёл
Jesse Hallam
родитель
a50e8ac5b9
Коммит
7a6f957638
@@ -84,6 +84,20 @@ func (api *PluginAPI) SaveConfig(config *model.Config) *model.AppError {
|
||||
return api.app.SaveConfig(config, true)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetPluginConfig() map[string]interface{} {
|
||||
cfg := api.app.GetConfig()
|
||||
if pluginConfig, isOk := cfg.PluginSettings.Plugins[api.manifest.Id]; isOk {
|
||||
return pluginConfig
|
||||
}
|
||||
return map[string]interface{}{}
|
||||
}
|
||||
|
||||
func (api *PluginAPI) SavePluginConfig(pluginConfig map[string]interface{}) *model.AppError {
|
||||
cfg := api.app.GetConfig()
|
||||
cfg.PluginSettings.Plugins[api.manifest.Id] = pluginConfig
|
||||
return api.app.SaveConfig(cfg, true)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetServerVersion() string {
|
||||
return model.CurrentVersion
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user