diff --git a/mm-go-irckit/userbridge.go b/mm-go-irckit/userbridge.go index 497ff026..bcc12361 100644 --- a/mm-go-irckit/userbridge.go +++ b/mm-go-irckit/userbridge.go @@ -808,7 +808,7 @@ func (u *User) addUserToChannelWorker6(channels <-chan *bridge.ChannelInfo, thro if postlist == nil { // if the channel is not from the primary team id, we can't get posts if brchannel.TeamID == u.br.GetMe().TeamID { - logger.Errorf("something wrong with getPostsSince for %s for channel %s (%s)", u.Nick, brchannel.ID, brchannel.Name) + logger.Errorf("something wrong with getPostsSince for %s for channel %s (%s)", u.Nick, channame, brchannel.ID) } continue } diff --git a/vendor/github.com/matterbridge/matterclient/channels.go b/vendor/github.com/matterbridge/matterclient/channels.go index 6bf22a68..07cc2b5d 100644 --- a/vendor/github.com/matterbridge/matterclient/channels.go +++ b/vendor/github.com/matterbridge/matterclient/channels.go @@ -224,8 +224,12 @@ func (m *Client) UpdateChannelsTeam(teamID string) error { } } + idx := 0 + max := 200 + channelmap := make(map[string]*model.Channel) + for { - mmchannels, resp, err = m.Client.GetPublicChannelsForTeam(teamID, 0, 5000, "") + mmchannels, resp, err = m.Client.GetPublicChannelsForTeam(teamID, idx, max, "") if err == nil { break } @@ -235,10 +239,36 @@ func (m *Client) UpdateChannelsTeam(teamID string) error { } } + for len(mmchannels) > 0 { + m.Lock() + + for _, channel := range mmchannels { + channelmap[channel.Id] = channel + } + + m.Unlock() + + for { + mmchannels, resp, err = m.Client.GetPublicChannelsForTeam(teamID, idx, max, "") + if err == nil { + idx++ + + break + } + + if err := m.HandleRatelimit("GetPublicChannelsForTeam", resp); err != nil { + return err + } + } + } + for idx, t := range m.OtherTeams { if t.ID == teamID { m.Lock() - m.OtherTeams[idx].MoreChannels = mmchannels + m.OtherTeams[idx].MoreChannels = make([]*model.Channel, 0) + for _, member := range channelmap { + m.OtherTeams[idx].MoreChannels = append(m.OtherTeams[idx].MoreChannels, member) + } m.Unlock() } } diff --git a/vendor/github.com/matterbridge/matterclient/matterclient.go b/vendor/github.com/matterbridge/matterclient/matterclient.go index 0652fe73..51e6aa86 100644 --- a/vendor/github.com/matterbridge/matterclient/matterclient.go +++ b/vendor/github.com/matterbridge/matterclient/matterclient.go @@ -334,6 +334,10 @@ func (m *Client) initUser() error { } m.logger.Infof("found %d users in team %s", len(usermap), team.Name) + // add all users + for k, v := range usermap { + m.Users[k] = v + } t := &Team{ Team: team, @@ -347,23 +351,43 @@ func (m *Client) initUser() error { } t.Channels = mmchannels + m.logger.Infof("found %d channels for user in team %s", len(mmchannels), team.Name) - mmchannels, _, err = m.Client.GetPublicChannelsForTeam(team.Id, 0, 5000, "") + idx = 0 + max = 200 + channelmap := make(map[string]*model.Channel) + + mmchannels, _, err = m.Client.GetPublicChannelsForTeam(team.Id, idx, max, "") if err != nil { return err } - t.MoreChannels = mmchannels + for len(mmchannels) > 0 { + for _, channel := range mmchannels { + channelmap[channel.Id] = channel + } + + mmchannels, _, err = m.Client.GetPublicChannelsForTeam(team.Id, idx, max, "") + if err != nil { + return err + } + + idx++ + + time.Sleep(time.Millisecond * 200) + } + + m.logger.Infof("found %d public channels in team %s", len(channelmap), team.Name) + // add all channels + for _, member := range channelmap { + t.MoreChannels = append(t.MoreChannels, member) + } m.OtherTeams = append(m.OtherTeams, t) if team.Name == m.Credentials.Team { m.Team = t m.logger.Debugf("initUser(): found our team %s (id: %s)", team.Name, team.Id) } - // add all users - for k, v := range t.Users { - m.Users[k] = v - } } return nil