diff options
author | Wim <wim@42.be> | 2019-05-02 00:46:49 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2019-05-02 00:46:49 +0200 |
commit | 1b2feb19e506bc24580d5d61422d0de68349c24e (patch) | |
tree | c4e65e9dbe87cc15a119a21cee0c29b276181033 /matterclient/channels.go | |
parent | 1829dc3d9f65ed04c6d4e4b604a71ca29f8dd911 (diff) | |
download | matterbridge-msglm-1b2feb19e506bc24580d5d61422d0de68349c24e.tar.gz matterbridge-msglm-1b2feb19e506bc24580d5d61422d0de68349c24e.tar.bz2 matterbridge-msglm-1b2feb19e506bc24580d5d61422d0de68349c24e.zip |
Update channels of all teams (mattermost)
Diffstat (limited to 'matterclient/channels.go')
-rw-r--r-- | matterclient/channels.go | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/matterclient/channels.go b/matterclient/channels.go index 0eac29f8..c09a170f 100644 --- a/matterclient/channels.go +++ b/matterclient/channels.go @@ -167,23 +167,38 @@ func (m *MMClient) JoinChannel(channelId string) error { //nolint:golint return nil } -func (m *MMClient) UpdateChannels() error { - mmchannels, resp := m.Client.GetChannelsForTeamForUser(m.Team.Id, m.User.Id, "") +func (m *MMClient) UpdateChannelsTeam(teamId string) error { + mmchannels, resp := m.Client.GetChannelsForTeamForUser(teamId, m.User.Id, "") if resp.Error != nil { return errors.New(resp.Error.DetailedError) } - m.Lock() - m.Team.Channels = mmchannels - m.Unlock() + for idx, t := range m.OtherTeams { + if t.Id == teamId { + m.Lock() + m.OtherTeams[idx].Channels = mmchannels + m.Unlock() + } + } - mmchannels, resp = m.Client.GetPublicChannelsForTeam(m.Team.Id, 0, 5000, "") + mmchannels, resp = m.Client.GetPublicChannelsForTeam(teamId, 0, 5000, "") if resp.Error != nil { return errors.New(resp.Error.DetailedError) } + for idx, t := range m.OtherTeams { + if t.Id == teamId { + m.Lock() + m.OtherTeams[idx].MoreChannels = mmchannels + m.Unlock() + } + } + return nil +} - m.Lock() - m.Team.MoreChannels = mmchannels - m.Unlock() +func (m *MMClient) UpdateChannels() error { + m.UpdateChannelsTeam(m.Team.Id) + for _, t := range m.OtherTeams { + m.UpdateChannelsTeam(t.Id) + } return nil } |