Update channels of all teams (mattermost)

This commit is contained in:
Wim 2019-05-02 00:46:49 +02:00
parent 1829dc3d9f
commit 1b2feb19e5

View File

@ -167,23 +167,38 @@ func (m *MMClient) JoinChannel(channelId string) error { //nolint:golint
return nil return nil
} }
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)
}
for idx, t := range m.OtherTeams {
if t.Id == teamId {
m.Lock()
m.OtherTeams[idx].Channels = mmchannels
m.Unlock()
}
}
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
}
func (m *MMClient) UpdateChannels() error { func (m *MMClient) UpdateChannels() error {
mmchannels, resp := m.Client.GetChannelsForTeamForUser(m.Team.Id, m.User.Id, "") m.UpdateChannelsTeam(m.Team.Id)
if resp.Error != nil { for _, t := range m.OtherTeams {
return errors.New(resp.Error.DetailedError) m.UpdateChannelsTeam(t.Id)
} }
m.Lock()
m.Team.Channels = mmchannels
m.Unlock()
mmchannels, resp = m.Client.GetPublicChannelsForTeam(m.Team.Id, 0, 5000, "")
if resp.Error != nil {
return errors.New(resp.Error.DetailedError)
}
m.Lock()
m.Team.MoreChannels = mmchannels
m.Unlock()
return nil return nil
} }