Add plugin slash command support (#7941)
* add plugin slash command support * remove unused string * rebase
Этот коммит содержится в:
@@ -30,6 +30,22 @@ func (m *API) LoadPluginConfiguration(dest interface{}) error {
|
||||
return ret.Error(0)
|
||||
}
|
||||
|
||||
func (m *API) RegisterCommand(command *model.Command) error {
|
||||
ret := m.Called(command)
|
||||
if f, ok := ret.Get(0).(func(*model.Command) error); ok {
|
||||
return f(command)
|
||||
}
|
||||
return ret.Error(0)
|
||||
}
|
||||
|
||||
func (m *API) UnregisterCommand(teamId, trigger string) error {
|
||||
ret := m.Called(teamId, trigger)
|
||||
if f, ok := ret.Get(0).(func(string, string) error); ok {
|
||||
return f(teamId, trigger)
|
||||
}
|
||||
return ret.Error(0)
|
||||
}
|
||||
|
||||
func (m *API) CreateUser(user *model.User) (*model.User, *model.AppError) {
|
||||
ret := m.Called(user)
|
||||
if f, ok := ret.Get(0).(func(*model.User) (*model.User, *model.AppError)); ok {
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/mock"
|
||||
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/mattermost/mattermost-server/plugin"
|
||||
)
|
||||
|
||||
@@ -18,7 +19,11 @@ type Hooks struct {
|
||||
var _ plugin.Hooks = (*Hooks)(nil)
|
||||
|
||||
func (m *Hooks) OnActivate(api plugin.API) error {
|
||||
return m.Called(api).Error(0)
|
||||
ret := m.Called(api)
|
||||
if f, ok := ret.Get(0).(func(plugin.API) error); ok {
|
||||
return f(api)
|
||||
}
|
||||
return ret.Error(0)
|
||||
}
|
||||
|
||||
func (m *Hooks) OnDeactivate() error {
|
||||
@@ -32,3 +37,13 @@ func (m *Hooks) OnConfigurationChange() error {
|
||||
func (m *Hooks) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
m.Called(w, r)
|
||||
}
|
||||
|
||||
func (m *Hooks) ExecuteCommand(args *model.CommandArgs) (*model.CommandResponse, *model.AppError) {
|
||||
ret := m.Called(args)
|
||||
if f, ok := ret.Get(0).(func(*model.CommandArgs) (*model.CommandResponse, *model.AppError)); ok {
|
||||
return f(args)
|
||||
}
|
||||
resp, _ := ret.Get(0).(*model.CommandResponse)
|
||||
err, _ := ret.Get(1).(*model.AppError)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user