Skip to content

Commit

Permalink
Fallback to use API for getting channel data when not in the cache (#490
Browse files Browse the repository at this point in the history
)
  • Loading branch information
hloeung authored Nov 6, 2022
1 parent 3dc91ce commit 2dcbc00
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion bridge/mattermost6/mattermost.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,18 @@ func (m *Mattermost) GetChannel(channelID string) (*bridge.ChannelInfo, error) {
}
}

return nil, errors.New("channel not found")
// Fallback if it's not found in the cache.
mmchannel, _, err := m.mc.Client.GetChannel(channelID, "")
if err != nil {
return nil, errors.New("channel not found")
}
return &bridge.ChannelInfo{
Name: mmchannel.Name,
ID: mmchannel.Id,
TeamID: mmchannel.TeamId,
DM: mmchannel.IsGroupOrDirect(),
Private: !mmchannel.IsOpen(),
}, nil
}

func (m *Mattermost) GetUser(userID string) *bridge.UserInfo {
Expand Down
2 changes: 1 addition & 1 deletion mm-go-irckit/userbridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 2dcbc00

Please sign in to comment.