diff options
author | Wim <wim@42.be> | 2019-04-20 23:06:06 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2019-04-20 23:06:06 +0200 |
commit | 9f5f0047259f7b28e6e26b762cff853ecacec599 (patch) | |
tree | c4dc363d3825c93cc5ca03c4406c0ce4ab4bad3f /matterclient/helpers.go | |
parent | fed77cccf3ca8104c60ffedbff130a1e520abfb7 (diff) | |
download | matterbridge-msglm-9f5f0047259f7b28e6e26b762cff853ecacec599.tar.gz matterbridge-msglm-9f5f0047259f7b28e6e26b762cff853ecacec599.tar.bz2 matterbridge-msglm-9f5f0047259f7b28e6e26b762cff853ecacec599.zip |
Use paging in initUser and UpdateUsers (mattermost)
Diffstat (limited to 'matterclient/helpers.go')
-rw-r--r-- | matterclient/helpers.go | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/matterclient/helpers.go b/matterclient/helpers.go index b3d43460..c3d33145 100644 --- a/matterclient/helpers.go +++ b/matterclient/helpers.go @@ -132,14 +132,25 @@ func (m *MMClient) initUser() error { return resp.Error } for _, team := range teams { - mmusers, resp := m.Client.GetUsersInTeam(team.Id, 0, 50000, "") + idx := 0 + max := 200 + usermap := make(map[string]*model.User) + mmusers, resp := m.Client.GetUsersInTeam(team.Id, idx, max, "") if resp.Error != nil { return errors.New(resp.Error.DetailedError) } - usermap := make(map[string]*model.User) - for _, user := range mmusers { - usermap[user.Id] = user + for len(mmusers) > 0 { + for _, user := range mmusers { + usermap[user.Id] = user + } + mmusers, resp = m.Client.GetUsersInTeam(team.Id, idx, max, "") + if resp.Error != nil { + return errors.New(resp.Error.DetailedError) + } + idx++ + time.Sleep(time.Millisecond * 200) } + m.logger.Infof("found %d users in team %s", len(usermap), team.Name) t := &Team{Team: team, Users: usermap, Id: team.Id} |