add GetChannelsForTeamForUser to plugin api (#9646)

This commit is contained in:
Daniel Hodan
2018-10-15 18:27:45 +02:00
committed by Christopher Speller
parent 3087f0bc4c
commit a35a9b9b2d
4 changed files with 63 additions and 0 deletions

View File

@@ -237,6 +237,10 @@ func (api *PluginAPI) GetChannelByNameForTeamName(teamName, channelName string,
return api.app.GetChannelByNameForTeamName(channelName, teamName, includeDeleted)
}
func (api *PluginAPI) GetChannelsForTeamForUser(teamId, userId string, includeDeleted bool) (*model.ChannelList, *model.AppError) {
return api.app.GetChannelsForUser(teamId, userId, includeDeleted)
}
func (api *PluginAPI) GetDirectChannel(userId1, userId2 string) (*model.Channel, *model.AppError) {
return api.app.GetDirectChannel(userId1, userId2)
}

View File

@@ -128,6 +128,9 @@ type API interface {
// GetChannelByNameForTeamName gets a channel by its name, given a team name.
GetChannelByNameForTeamName(teamName, channelName string, includeDeleted bool) (*model.Channel, *model.AppError)
// GetChannelsForTeamForUser gets a list of channels for given user ID in given team ID.
GetChannelsForTeamForUser(teamId, userId string, includeDeleted bool) (*model.ChannelList, *model.AppError)
// GetDirectChannel gets a direct message channel.
GetDirectChannel(userId1, userId2 string) (*model.Channel, *model.AppError)

View File

@@ -1539,6 +1539,37 @@ func (s *apiRPCServer) GetChannelByNameForTeamName(args *Z_GetChannelByNameForTe
return nil
}
type Z_GetChannelsForTeamForUserArgs struct {
A string
B string
C bool
}
type Z_GetChannelsForTeamForUserReturns struct {
A *model.ChannelList
B *model.AppError
}
func (g *apiRPCClient) GetChannelsForTeamForUser(teamId, userId string, includeDeleted bool) (*model.ChannelList, *model.AppError) {
_args := &Z_GetChannelsForTeamForUserArgs{teamId, userId, includeDeleted}
_returns := &Z_GetChannelsForTeamForUserReturns{}
if err := g.client.Call("Plugin.GetChannelsForTeamForUser", _args, _returns); err != nil {
log.Printf("RPC call to GetChannelsForTeamForUser API failed: %s", err.Error())
}
return _returns.A, _returns.B
}
func (s *apiRPCServer) GetChannelsForTeamForUser(args *Z_GetChannelsForTeamForUserArgs, returns *Z_GetChannelsForTeamForUserReturns) error {
if hook, ok := s.impl.(interface {
GetChannelsForTeamForUser(teamId, userId string, includeDeleted bool) (*model.ChannelList, *model.AppError)
}); ok {
returns.A, returns.B = hook.GetChannelsForTeamForUser(args.A, args.B, args.C)
} else {
return encodableError(fmt.Errorf("API GetChannelsForTeamForUser called but not implemented."))
}
return nil
}
type Z_GetDirectChannelArgs struct {
A string
B string

View File

@@ -458,6 +458,31 @@ func (_m *API) GetChannelMembers(channelId string, page int, perPage int) (*mode
return r0, r1
}
// GetChannelsForTeamForUser provides a mock function with given fields: teamId, userId, includeDeleted
func (_m *API) GetChannelsForTeamForUser(teamId string, userId string, includeDeleted bool) (*model.ChannelList, *model.AppError) {
ret := _m.Called(teamId, userId, includeDeleted)
var r0 *model.ChannelList
if rf, ok := ret.Get(0).(func(string, string, bool) *model.ChannelList); ok {
r0 = rf(teamId, userId, includeDeleted)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.ChannelList)
}
}
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, string, bool) *model.AppError); ok {
r1 = rf(teamId, userId, includeDeleted)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
}
return r0, r1
}
// GetConfig provides a mock function with given fields:
func (_m *API) GetConfig() *model.Config {
ret := _m.Called()