From a35a9b9b2d9720a3753c96a4a3a36d437e518140 Mon Sep 17 00:00:00 2001 From: Daniel Hodan Date: Mon, 15 Oct 2018 18:27:45 +0200 Subject: add GetChannelsForTeamForUser to plugin api (#9646) --- app/plugin_api.go | 4 ++++ plugin/api.go | 3 +++ plugin/client_rpc_generated.go | 31 +++++++++++++++++++++++++++++++ plugin/plugintest/api.go | 25 +++++++++++++++++++++++++ 4 files changed, 63 insertions(+) diff --git a/app/plugin_api.go b/app/plugin_api.go index 1deb45802..c57ca9eb5 100644 --- a/app/plugin_api.go +++ b/app/plugin_api.go @@ -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) } diff --git a/plugin/api.go b/plugin/api.go index 004d4c1ff..e0b3dde3c 100644 --- a/plugin/api.go +++ b/plugin/api.go @@ -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) diff --git a/plugin/client_rpc_generated.go b/plugin/client_rpc_generated.go index 8522f7be4..cf865f78c 100644 --- a/plugin/client_rpc_generated.go +++ b/plugin/client_rpc_generated.go @@ -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 diff --git a/plugin/plugintest/api.go b/plugin/plugintest/api.go index b915a6105..a65b3a5d7 100644 --- a/plugin/plugintest/api.go +++ b/plugin/plugintest/api.go @@ -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() -- cgit v1.2.3-1-g7c22