Commit 359f12db authored by Daniel Schalla's avatar Daniel Schalla Committed by Christopher Speller

First batch of new plugin api methods (#9022)

update api mocks

Generated new hooks

ChannelHasJoinedChannel Implementation

User Left Team/Channel Hook; User Joined Team Hook Implementation

Update RPC Client and Mocks

gofmt

go tests fix

Add Config API Methods

codegne

Add Channel Has Been Created Hook

Fix ChannelHasBeenCreated hook

fix missing context param

fix duplicate hooks; remove redudandcy
parent 4c1ddcff
......@@ -1837,9 +1837,6 @@ func TestRemoveChannelMember(t *testing.T) {
t.Fatal("should have passed")
}
_, resp = Client.RemoveUserFromChannel(th.BasicChannel.Id, th.BasicUser2.Id)
CheckNoError(t, resp)
_, resp = Client.RemoveUserFromChannel(th.BasicChannel.Id, "junk")
CheckBadRequestStatus(t, resp)
......
......@@ -11,6 +11,7 @@ import (
"github.com/mattermost/mattermost-server/mlog"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/plugin"
"github.com/mattermost/mattermost-server/store"
"github.com/mattermost/mattermost-server/utils"
)
......@@ -183,6 +184,16 @@ func (a *App) CreateChannel(channel *model.Channel, addMember bool) (*model.Chan
a.InvalidateCacheForUser(channel.CreatorId)
}
if a.PluginsReady() {
a.Go(func() {
pluginContext := &plugin.Context{}
a.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
hooks.ChannelHasBeenCreated(pluginContext, sc)
return true
}, plugin.ChannelHasBeenCreatedId)
})
}
return sc, nil
}
}
......@@ -200,6 +211,16 @@ func (a *App) CreateDirectChannel(userId string, otherUserId string) (*model.Cha
a.InvalidateCacheForUser(userId)
a.InvalidateCacheForUser(otherUserId)
if a.PluginsReady() {
a.Go(func() {
pluginContext := &plugin.Context{}
a.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
hooks.ChannelHasBeenCreated(pluginContext, channel)
return true
}, plugin.ChannelHasBeenCreatedId)
})
}
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_DIRECT_ADDED, "", channel.Id, "", nil)
message.Add("teammate_id", otherUserId)
a.Publish(message)
......@@ -774,6 +795,16 @@ func (a *App) AddChannelMember(userId string, channel *model.Channel, userReques
return nil, err
}
if a.PluginsReady() {
a.Go(func() {
pluginContext := &plugin.Context{}
a.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
hooks.UserHasJoinedChannel(pluginContext, cm, userRequestor)
return true
}, plugin.UserHasJoinedChannelId)
})
}
if userRequestorId == "" || userId == userRequestorId {
a.postJoinChannelMessage(user, channel)
} else {
......@@ -1104,10 +1135,21 @@ func (a *App) JoinChannel(channel *model.Channel, userId string) *model.AppError
user := uresult.Data.(*model.User)
if channel.Type == model.CHANNEL_OPEN {
if _, err := a.AddUserToChannel(user, channel); err != nil {
cm, err := a.AddUserToChannel(user, channel)
if err != nil {
return err
}
if a.PluginsReady() {
a.Go(func() {
pluginContext := &plugin.Context{}
a.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
hooks.UserHasJoinedChannel(pluginContext, cm, nil)
return true
}, plugin.UserHasJoinedChannelId)
})
}
if err := a.postJoinChannelMessage(user, channel); err != nil {
return err
}
......@@ -1288,6 +1330,11 @@ func (a *App) removeUserFromChannel(userIdToRemove string, removerUserId string,
return model.NewAppError("RemoveUserFromChannel", "api.channel.remove.default.app_error", map[string]interface{}{"Channel": model.DEFAULT_CHANNEL}, "", http.StatusBadRequest)
}
cm, err := a.GetChannelMember(channel.Id, userIdToRemove)
if err != nil {
return err
}
if cmresult := <-a.Srv.Store.Channel().RemoveMember(channel.Id, userIdToRemove); cmresult.Err != nil {
return cmresult.Err
}
......@@ -1298,6 +1345,22 @@ func (a *App) removeUserFromChannel(userIdToRemove string, removerUserId string,
a.InvalidateCacheForUser(userIdToRemove)
a.InvalidateCacheForChannelMembers(channel.Id)
if a.PluginsReady() {
var actorUser *model.User
if removerUserId != "" {
actorUser, err = a.GetUser(removerUserId)
}
a.Go(func() {
pluginContext := &plugin.Context{}
a.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
hooks.UserHasLeftChannel(pluginContext, cm, actorUser)
return true
}, plugin.UserHasLeftChannelId)
})
}
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_USER_REMOVED, "", channel.Id, "", nil)
message.Add("user_id", userIdToRemove)
message.Add("remover_id", removerUserId)
......@@ -1314,6 +1377,7 @@ func (a *App) removeUserFromChannel(userIdToRemove string, removerUserId string,
func (a *App) RemoveUserFromChannel(userIdToRemove string, removerUserId string, channel *model.Channel) *model.AppError {
var err *model.AppError
if err = a.removeUserFromChannel(userIdToRemove, removerUserId, channel); err != nil {
return err
}
......@@ -1326,6 +1390,11 @@ func (a *App) RemoveUserFromChannel(userIdToRemove string, removerUserId string,
if userIdToRemove == removerUserId {
a.postLeaveChannelMessage(user, channel)
} else {
if err != nil {
return err
}
a.Go(func() {
a.postRemoveFromChannelMessage(removerUserId, user, channel)
})
......
......@@ -42,6 +42,14 @@ func (api *PluginAPI) UnregisterCommand(teamId, trigger string) error {
return nil
}
func (api *PluginAPI) GetConfig() *model.Config {
return api.app.GetConfig()
}
func (api *PluginAPI) SaveConfig(config *model.Config) *model.AppError {
return api.app.SaveConfig(config, true)
}
func (api *PluginAPI) CreateTeam(team *model.Team) (*model.Team, *model.AppError) {
return api.app.CreateTeam(team)
}
......@@ -50,6 +58,10 @@ func (api *PluginAPI) DeleteTeam(teamId string) *model.AppError {
return api.app.SoftDeleteTeam(teamId)
}
func (api *PluginAPI) GetTeams() ([]*model.Team, *model.AppError) {
return api.app.GetAllTeams()
}
func (api *PluginAPI) GetTeam(teamId string) (*model.Team, *model.AppError) {
return api.app.GetTeam(teamId)
}
......@@ -62,6 +74,30 @@ func (api *PluginAPI) UpdateTeam(team *model.Team) (*model.Team, *model.AppError
return api.app.UpdateTeam(team)
}
func (api *PluginAPI) CreateTeamMember(teamId, userId string) (*model.TeamMember, *model.AppError) {
return api.app.AddTeamMember(teamId, userId)
}
func (api *PluginAPI) CreateTeamMembers(teamId string, userIds []string, requestorId string) ([]*model.TeamMember, *model.AppError) {
return api.app.AddTeamMembers(teamId, userIds, requestorId)
}
func (api *PluginAPI) DeleteTeamMember(teamId, userId, requestorId string) *model.AppError {
return api.app.RemoveUserFromTeam(teamId, userId, requestorId)
}
func (api *PluginAPI) GetTeamMembers(teamId string, offset, limit int) ([]*model.TeamMember, *model.AppError) {
return api.app.GetTeamMembers(teamId, offset, limit)
}
func (api *PluginAPI) GetTeamMember(teamId, userId string) (*model.TeamMember, *model.AppError) {
return api.app.GetTeamMember(teamId, userId)
}
func (api *PluginAPI) UpdateTeamMemberRoles(teamId, userId, newRoles string) (*model.TeamMember, *model.AppError) {
return api.app.UpdateTeamMemberRoles(teamId, userId, newRoles)
}
func (api *PluginAPI) CreateUser(user *model.User) (*model.User, *model.AppError) {
return api.app.CreateUser(user)
}
......@@ -103,6 +139,10 @@ func (api *PluginAPI) DeleteChannel(channelId string) *model.AppError {
return api.app.DeleteChannel(channel, "")
}
func (api *PluginAPI) GetPublicChannelsForTeam(teamId string, offset, limit int) (*model.ChannelList, *model.AppError) {
return api.app.GetPublicChannelsForTeam(teamId, offset, limit)
}
func (api *PluginAPI) GetChannel(channelId string) (*model.Channel, *model.AppError) {
return api.app.GetChannel(channelId)
}
......@@ -156,6 +196,10 @@ func (api *PluginAPI) CreatePost(post *model.Post) (*model.Post, *model.AppError
return api.app.CreatePostMissingChannel(post, true)
}
func (api *PluginAPI) SendEphemeralPost(userId string, post *model.Post) *model.Post {
return api.app.SendEphemeralPost(userId, post)
}
func (api *PluginAPI) DeletePost(postId string) *model.AppError {
_, err := api.app.DeletePost(postId, api.id)
return err
......
......@@ -17,6 +17,7 @@ import (
"github.com/mattermost/mattermost-server/mlog"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/plugin"
"github.com/mattermost/mattermost-server/utils"
)
......@@ -429,12 +430,28 @@ func (a *App) joinUserToTeam(team *model.Team, user *model.User) (*model.TeamMem
}
func (a *App) JoinUserToTeam(team *model.Team, user *model.User, userRequestorId string) *model.AppError {
if _, alreadyAdded, err := a.joinUserToTeam(team, user); err != nil {
tm, alreadyAdded, err := a.joinUserToTeam(team, user)
if err != nil {
return err
} else if alreadyAdded {
return nil
}
if a.PluginsReady() {
var actor *model.User
if userRequestorId != "" {
actor, err = a.GetUser(userRequestorId)
}
a.Go(func() {
pluginContext := &plugin.Context{}
a.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
hooks.UserHasJoinedTeam(pluginContext, tm, actor)
return true
}, plugin.UserHasJoinedTeamId)
})
}
if uua := <-a.Srv.Store.User().UpdateUpdateAt(user.Id); uua.Err != nil {
return uua.Err
}
......@@ -575,9 +592,8 @@ func (a *App) AddTeamMember(teamId, userId string) (*model.TeamMember, *model.Ap
return nil, err
}
var teamMember *model.TeamMember
var err *model.AppError
if teamMember, err = a.GetTeamMember(teamId, userId); err != nil {
teamMember, err := a.GetTeamMember(teamId, userId)
if err != nil {
return nil, err
}
......@@ -692,10 +708,8 @@ func (a *App) RemoveUserFromTeam(teamId string, userId string, requestorId strin
}
func (a *App) LeaveTeam(team *model.Team, user *model.User, requestorId string) *model.AppError {
var teamMember *model.TeamMember
var err *model.AppError
if teamMember, err = a.GetTeamMember(team.Id, user.Id); err != nil {
teamMember, err := a.GetTeamMember(team.Id, user.Id)
if err != nil {
return model.NewAppError("LeaveTeam", "api.team.remove_user_from_team.missing.app_error", nil, err.Error(), http.StatusBadRequest)
}
......@@ -753,6 +767,21 @@ func (a *App) LeaveTeam(team *model.Team, user *model.User, requestorId string)
return result.Err
}
if a.PluginsReady() {
var actor *model.User
if requestorId != "" {
actor, err = a.GetUser(requestorId)
}
a.Go(func() {
pluginContext := &plugin.Context{}
a.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
hooks.UserHasLeftTeam(pluginContext, teamMember, actor)
return true
}, plugin.UserHasLeftTeamId)
})
}
if uua := <-a.Srv.Store.User().UpdateUpdateAt(user.Id); uua.Err != nil {
return uua.Err
}
......
......@@ -24,6 +24,12 @@ type API interface {
// UnregisterCommand unregisters a command previously registered via RegisterCommand.
UnregisterCommand(teamId, trigger string) error
// GetConfig fetches the currently persisted config
GetConfig() *model.Config
// SaveConfig sets the given config and persists the changes
SaveConfig(config *model.Config) *model.AppError
// CreateUser creates a user.
CreateUser(user *model.User) (*model.User, *model.AppError)
......@@ -48,6 +54,9 @@ type API interface {
// DeleteTeam deletes a team.
DeleteTeam(teamId string) *model.AppError
// GetTeam gets all teams.
GetTeams() ([]*model.Team, *model.AppError)
// GetTeam gets a team.
GetTeam(teamId string) (*model.Team, *model.AppError)
......@@ -57,12 +66,33 @@ type API interface {
// UpdateTeam updates a team.
UpdateTeam(team *model.Team) (*model.Team, *model.AppError)
// CreateTeamMember creates a team membership.
CreateTeamMember(teamId, userId string) (*model.TeamMember, *model.AppError)
// CreateTeamMember creates a team membership for all provided user ids.
CreateTeamMembers(teamId string, userIds []string, requestorId string) ([]*model.TeamMember, *model.AppError)
// DeleteTeamMember deletes a team membership.
DeleteTeamMember(teamId, userId, requestorId string) *model.AppError
// GetTeamMembers returns the memberships of a specific team.
GetTeamMembers(teamId string, offset, limit int) ([]*model.TeamMember, *model.AppError)
// GetTeamMember returns a specific membership.
GetTeamMember(teamId, userId string) (*model.TeamMember, *model.AppError)
// UpdateTeamMemberRoles updates the role for a team membership.
UpdateTeamMemberRoles(teamId, userId, newRoles string) (*model.TeamMember, *model.AppError)
// CreateChannel creates a channel.
CreateChannel(channel *model.Channel) (*model.Channel, *model.AppError)
// DeleteChannel deletes a channel.
DeleteChannel(channelId string) *model.AppError
// GetChannels gets a list of all channels.
GetPublicChannelsForTeam(teamId string, offset, limit int) (*model.ChannelList, *model.AppError)
// GetChannel gets a channel.
GetChannel(channelId string) (*model.Channel, *model.AppError)
......@@ -96,6 +126,9 @@ type API interface {
// CreatePost creates a post.
CreatePost(post *model.Post) (*model.Post, *model.AppError)
// SendEphemeralPost creates an ephemeral post.
SendEphemeralPost(userId string, post *model.Post) *model.Post
// DeletePost deletes a post.
DeletePost(postId string) *model.AppError
......
This diff is collapsed.
......@@ -21,6 +21,11 @@ const (
MessageWillBeUpdatedId = 6
MessageHasBeenPostedId = 7
MessageHasBeenUpdatedId = 8
UserHasJoinedChannelId = 9
UserHasLeftChannelId = 10
UserHasJoinedTeamId = 11
UserHasLeftTeamId = 12
ChannelHasBeenCreatedId = 13
TotalHooksId = iota
)
......@@ -54,7 +59,7 @@ type Hooks interface {
// API.
ExecuteCommand(c *Context, args *model.CommandArgs) (*model.CommandResponse, *model.AppError)
// MessageWillBePosted is invoked when a message is posted by a user before it is commited
// MessageWillBePosted is invoked when a message is posted by a user before it is committed
// to the database. If you also want to act on edited posts, see MessageWillBeUpdated.
// Return values should be the modified post or nil if rejected and an explanation for the user.
//
......@@ -64,7 +69,7 @@ type Hooks interface {
// created the post.
MessageWillBePosted(c *Context, post *model.Post) (*model.Post, string)
// MessageWillBeUpdated is invoked when a message is updated by a user before it is commited
// MessageWillBeUpdated is invoked when a message is updated by a user before it is committed
// to the database. If you also want to act on new posts, see MessageWillBePosted.
// Return values should be the modified post or nil if rejected and an explanation for the user.
// On rejection, the post will be kept in its previous state.
......@@ -75,15 +80,34 @@ type Hooks interface {
// updated the post.
MessageWillBeUpdated(c *Context, newPost, oldPost *model.Post) (*model.Post, string)
// MessageHasBeenPosted is invoked after the message has been commited to the databse.
// MessageHasBeenPosted is invoked after the message has been committed to the database.
// If you need to modify or reject the post, see MessageWillBePosted
// Note that this method will be called for posts created by plugins, including the plugin that
// created the post.
MessageHasBeenPosted(c *Context, post *model.Post)
// MessageHasBeenUpdated is invoked after a message is updated and has been updated in the databse.
// MessageHasBeenUpdated is invoked after a message is updated and has been updated in the database.
// If you need to modify or reject the post, see MessageWillBeUpdated
// Note that this method will be called for posts created by plugins, including the plugin that
// created the post.
MessageHasBeenUpdated(c *Context, newPost, oldPost *model.Post)
// ChannelHasBeenCreated is invoked after the channel has been committed to the database.
ChannelHasBeenCreated(c *Context, channel *model.Channel)
// UserHasJoinedChannel is invoked after the membership has been committed to the database.
// If actor is not nil, the user was invited to the channel by the actor.
UserHasJoinedChannel(c *Context, channelMember *model.ChannelMember, actor *model.User)
// UserHasLeftChannel is invoked after the membership has been removed from the database.
// If actor is not nil, the user was removed from the channel by the actor.
UserHasLeftChannel(c *Context, channelMember *model.ChannelMember, actor *model.User)
// UserHasJoinedTeam is invoked after the membership has been committed to the database.
// If actor is not nil, the user was added to the team by the actor.
UserHasJoinedTeam(c *Context, teamMember *model.TeamMember, actor *model.User)
// UserHasLeftTeam is invoked after the membership has been removed from the database.
// If actor is not nil, the user was removed from the team by the actor.
UserHasLeftTeam(c *Context, teamMember *model.TeamMember, actor *model.User)
}
......@@ -112,6 +112,56 @@ func (_m *MockAPI) CreateTeam(team *model.Team) (*model.Team, *model.AppError) {
return r0, r1
}
// CreateTeamMember provides a mock function with given fields: teamId, userId
func (_m *MockAPI) CreateTeamMember(teamId string, userId string) (*model.TeamMember, *model.AppError) {
ret := _m.Called(teamId, userId)
var r0 *model.TeamMember
if rf, ok := ret.Get(0).(func(string, string) *model.TeamMember); ok {
r0 = rf(teamId, userId)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.TeamMember)
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok {
r1 = rf(teamId, userId)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
}
return r0, r1
}
// CreateTeamMembers provides a mock function with given fields: teamId, userIds, requestorId
func (_m *MockAPI) CreateTeamMembers(teamId string, userIds []string, requestorId string) ([]*model.TeamMember, *model.AppError) {
ret := _m.Called(teamId, userIds, requestorId)
var r0 []*model.TeamMember
if rf, ok := ret.Get(0).(func(string, []string, string) []*model.TeamMember); ok {
r0 = rf(teamId, userIds, requestorId)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]*model.TeamMember)
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, []string, string) *model.AppError); ok {
r1 = rf(teamId, userIds, requestorId)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
}
return r0, r1
}
// CreateUser provides a mock function with given fields: user
func (_m *MockAPI) CreateUser(user *model.User) (*model.User, *model.AppError) {
ret := _m.Called(user)
......@@ -201,6 +251,22 @@ func (_m *MockAPI) DeleteTeam(teamId string) *model.AppError {
return r0
}
// DeleteTeamMember provides a mock function with given fields: teamId, userId, requestorId
func (_m *MockAPI) DeleteTeamMember(teamId string, userId string, requestorId string) *model.AppError {
ret := _m.Called(teamId, userId, requestorId)
var r0 *model.AppError
if rf, ok := ret.Get(0).(func(string, string, string) *model.AppError); ok {
r0 = rf(teamId, userId, requestorId)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.AppError)
}
}
return r0
}
// DeleteUser provides a mock function with given fields: userId
func (_m *MockAPI) DeleteUser(userId string) *model.AppError {
ret := _m.Called(userId)
......@@ -292,6 +358,22 @@ func (_m *MockAPI) GetChannelMember(channelId string, userId string) (*model.Cha
return r0, r1
}
// GetConfig provides a mock function with given fields:
func (_m *MockAPI) GetConfig() *model.Config {
ret := _m.Called()
var r0 *model.Config
if rf, ok := ret.Get(0).(func() *model.Config); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.Config)
}
}
return r0
}
// GetDirectChannel provides a mock function with given fields: userId1, userId2
func (_m *MockAPI) GetDirectChannel(userId1 string, userId2 string) (*model.Channel, *model.AppError) {
ret := _m.Called(userId1, userId2)
......@@ -367,6 +449,31 @@ func (_m *MockAPI) GetPost(postId string) (*model.Post, *model.AppError) {
return r0, r1
}
// GetPublicChannelsForTeam provides a mock function with given fields: teamId, offset, limit
func (_m *MockAPI) GetPublicChannelsForTeam(teamId string, offset int, limit int) (*model.ChannelList, *model.AppError) {
ret := _m.Called(teamId, offset, limit)
var r0 *model.ChannelList
if rf, ok := ret.Get(0).(func(string, int, int) *model.ChannelList); ok {
r0 = rf(teamId, offset, limit)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.ChannelList)
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, int, int) *model.AppError); ok {
r1 = rf(teamId, offset, limit)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
}
return r0, r1
}
// GetTeam provides a mock function with given fields: teamId
func (_m *MockAPI) GetTeam(teamId string) (*model.Team, *model.AppError) {
ret := _m.Called(teamId)
......@@ -417,6 +524,81 @@ func (_m *MockAPI) GetTeamByName(name string) (*model.Team, *model.AppError) {
return r0, r1
}
// GetTeamMember provides a mock function with given fields: teamId, userId
func (_m *MockAPI) GetTeamMember(teamId string, userId string) (*model.TeamMember, *model.AppError) {
ret := _m.Called(teamId, userId)
var r0 *model.TeamMember
if rf, ok := ret.Get(0).(func(string, string) *model.TeamMember); ok {
r0 = rf(teamId, userId)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.TeamMember)
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok {
r1 = rf(teamId, userId)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
}
return r0, r1
}
// GetTeamMembers provides a mock function with given fields: teamId, offset, limit
func (_m *MockAPI) GetTeamMembers(teamId string, offset int, limit int) ([]*model.TeamMember, *model.AppError) {
ret := _m.Called(teamId, offset, limit)
var r0 []*model.TeamMember
if rf, ok := ret.Get(0).(func(string, int, int) []*model.TeamMember); ok {
r0 = rf(teamId, offset, limit)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]*model.TeamMember)
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, int, int) *model.AppError); ok {
r1 = rf(teamId, offset, limit)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
}
return r0, r1
}
// GetTeams provides a mock function with given fields:
func (_m *MockAPI) GetTeams() ([]*model.Team, *model.AppError) {
ret := _m.Called()
var r0 []*model.Team
if rf, ok := ret.Get(0).(func() []*model.Team); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]*model.Team)
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func() *model.AppError); ok {
r1 = rf()
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
}
return r0, r1
}
// GetUser provides a mock function with given fields: userId
func (_m *MockAPI) GetUser(userId string) (*model.User, *model.AppError) {
ret := _m.Called(userId)
......@@ -614,6 +796,38 @@ func (_m *MockAPI) RegisterCommand(command *model.Command) error {
return r0
}
// SaveConfig provides a mock function with given fields: config
func (_m *MockAPI) SaveConfig(config *model.Config) *model.AppError {
ret := _m.Called(config)
var r0 *model.AppError
if rf, ok := ret.Get(0).(func(*model.Config) *model.AppError); ok {
r0 = rf(config)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.AppError)
}
}
return r0
}
// SendEphemeralPost provides a mock function with given fields: userId, post
func (_m *MockAPI) SendEphemeralPost(userId string, post *model.Post) *model.Post {
ret := _m.Called(userId, post)
var r0 *model.Post
if rf<