Skip to content

Commit

Permalink
Fallback to use API for getting channel data when not in the cache
Browse files Browse the repository at this point in the history
  • Loading branch information
hloeung committed Nov 4, 2022
1 parent 1275ae8 commit e583ee8
Show file tree
Hide file tree
Showing 2 changed files with 19 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 @@ -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
8 changes: 7 additions & 1 deletion vendor/github.com/matterbridge/matterclient/channels.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e583ee8

Please sign in to comment.