Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback to use API for getting channel data when not in the cache #490

Merged
merged 1 commit into from
Nov 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion bridge/mattermost6/mattermost.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,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