Unregistering plugin commands on disabling of plugin. (#10086)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
6d30b21dd2
Коммит
09a519799f
@@ -286,6 +286,7 @@ func (a *App) DisablePlugin(id string) *model.AppError {
|
|||||||
a.UpdateConfig(func(cfg *model.Config) {
|
a.UpdateConfig(func(cfg *model.Config) {
|
||||||
cfg.PluginSettings.PluginStates[id] = &model.PluginState{Enable: false}
|
cfg.PluginSettings.PluginStates[id] = &model.PluginState{Enable: false}
|
||||||
})
|
})
|
||||||
|
a.UnregisterPluginCommands(id)
|
||||||
|
|
||||||
if err := a.SaveConfig(a.Config(), true); err != nil {
|
if err := a.SaveConfig(a.Config(), true); err != nil {
|
||||||
return model.NewAppError("DisablePlugin", "app.plugin.config.app_error", nil, err.Error(), http.StatusInternalServerError)
|
return model.NewAppError("DisablePlugin", "app.plugin.config.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/mattermost/mattermost-server/model"
|
"github.com/mattermost/mattermost-server/model"
|
||||||
|
"github.com/mattermost/mattermost-server/utils"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -65,6 +66,8 @@ func TestPluginCommand(t *testing.T) {
|
|||||||
TeamId: p.configuration.TeamId,
|
TeamId: p.configuration.TeamId,
|
||||||
Trigger: "plugin",
|
Trigger: "plugin",
|
||||||
DisplayName: "Plugin Command",
|
DisplayName: "Plugin Command",
|
||||||
|
AutoComplete: true,
|
||||||
|
AutoCompleteDesc: "autocomplete",
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.API.LogError("error", "err", err)
|
p.API.LogError("error", "err", err)
|
||||||
@@ -94,6 +97,16 @@ func TestPluginCommand(t *testing.T) {
|
|||||||
require.Equal(t, model.COMMAND_RESPONSE_TYPE_EPHEMERAL, resp.ResponseType)
|
require.Equal(t, model.COMMAND_RESPONSE_TYPE_EPHEMERAL, resp.ResponseType)
|
||||||
require.Equal(t, "text", resp.Text)
|
require.Equal(t, "text", resp.Text)
|
||||||
|
|
||||||
|
err2 := th.App.DisablePlugin(pluginIds[0])
|
||||||
|
require.Nil(t, err2)
|
||||||
|
|
||||||
|
commands, err3 := th.App.ListAutocompleteCommands(args.TeamId, utils.T)
|
||||||
|
require.Nil(t, err3)
|
||||||
|
|
||||||
|
for _, commands := range commands {
|
||||||
|
require.NotEqual(t, "plugin", commands.Trigger)
|
||||||
|
}
|
||||||
|
|
||||||
th.App.RemovePlugin(pluginIds[0])
|
th.App.RemovePlugin(pluginIds[0])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user