diff options
author | Daniel Hodan <daniel.hodan@czertbytes.de> | 2018-10-17 16:37:52 +0200 |
---|---|---|
committer | Jesse Hallam <jesse.hallam@gmail.com> | 2018-10-17 10:37:52 -0400 |
commit | e8c9ccaa7e47f1cba3d2b126f6ebbb092fa43235 (patch) | |
tree | 4c82fde308452da5f591eec5dc6d076fae7c5756 /plugin | |
parent | 722675983107d0a8d5004bc1e076962786d603f0 (diff) | |
download | chat-e8c9ccaa7e47f1cba3d2b126f6ebbb092fa43235.tar.gz chat-e8c9ccaa7e47f1cba3d2b126f6ebbb092fa43235.tar.bz2 chat-e8c9ccaa7e47f1cba3d2b126f6ebbb092fa43235.zip |
GH-9607: Add GetTeamsForUser to plugin API (#9644)
* add GetTeamsForUser to plugin api
* Add version comment, fix comment typo
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/api.go | 5 | ||||
-rw-r--r-- | plugin/client_rpc_generated.go | 29 | ||||
-rw-r--r-- | plugin/plugintest/api.go | 25 |
3 files changed, 59 insertions, 0 deletions
diff --git a/plugin/api.go b/plugin/api.go index 19425bf04..c2429538d 100644 --- a/plugin/api.go +++ b/plugin/api.go @@ -98,6 +98,11 @@ type API interface { // UpdateTeam updates a team. UpdateTeam(team *model.Team) (*model.Team, *model.AppError) + // GetTeamsForUser returns list of teams of given user ID. + // + // Minimum server version: 5.6 + GetTeamsForUser(userId string) ([]*model.Team, *model.AppError) + // CreateTeamMember creates a team membership. CreateTeamMember(teamId, userId string) (*model.TeamMember, *model.AppError) diff --git a/plugin/client_rpc_generated.go b/plugin/client_rpc_generated.go index b53f10aff..5c14f4d4a 100644 --- a/plugin/client_rpc_generated.go +++ b/plugin/client_rpc_generated.go @@ -1177,6 +1177,35 @@ func (s *apiRPCServer) UpdateTeam(args *Z_UpdateTeamArgs, returns *Z_UpdateTeamR return nil } +type Z_GetTeamsForUserArgs struct { + A string +} + +type Z_GetTeamsForUserReturns struct { + A []*model.Team + B *model.AppError +} + +func (g *apiRPCClient) GetTeamsForUser(userId string) ([]*model.Team, *model.AppError) { + _args := &Z_GetTeamsForUserArgs{userId} + _returns := &Z_GetTeamsForUserReturns{} + if err := g.client.Call("Plugin.GetTeamsForUser", _args, _returns); err != nil { + log.Printf("RPC call to GetTeamsForUser API failed: %s", err.Error()) + } + return _returns.A, _returns.B +} + +func (s *apiRPCServer) GetTeamsForUser(args *Z_GetTeamsForUserArgs, returns *Z_GetTeamsForUserReturns) error { + if hook, ok := s.impl.(interface { + GetTeamsForUser(userId string) ([]*model.Team, *model.AppError) + }); ok { + returns.A, returns.B = hook.GetTeamsForUser(args.A) + } else { + return encodableError(fmt.Errorf("API GetTeamsForUser called but not implemented.")) + } + return nil +} + type Z_CreateTeamMemberArgs struct { A string B string diff --git a/plugin/plugintest/api.go b/plugin/plugintest/api.go index d17c9dc5c..066cdfa7e 100644 --- a/plugin/plugintest/api.go +++ b/plugin/plugintest/api.go @@ -988,6 +988,31 @@ func (_m *API) GetTeams() ([]*model.Team, *model.AppError) { return r0, r1 } +// GetTeamsForUser provides a mock function with given fields: userId +func (_m *API) GetTeamsForUser(userId string) ([]*model.Team, *model.AppError) { + ret := _m.Called(userId) + + var r0 []*model.Team + if rf, ok := ret.Get(0).(func(string) []*model.Team); ok { + r0 = rf(userId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*model.Team) + } + } + + var r1 *model.AppError + if rf, ok := ret.Get(1).(func(string) *model.AppError); ok { + r1 = rf(userId) + } 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 *API) GetUser(userId string) (*model.User, *model.AppError) { ret := _m.Called(userId) |