5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-11-26 05:31:34 +00:00

Use cache for teamid

This commit is contained in:
Wim 2017-06-12 20:30:30 +02:00
parent 41a46526a1
commit 860a371eeb

View File

@ -295,8 +295,7 @@ func (m *MMClient) parseActionPost(rmsg *Message) {
// edit messsages have no team_id for some reason // edit messsages have no team_id for some reason
if teamid == "" { if teamid == "" {
// we can find the team_id from the channelid // we can find the team_id from the channelid
result, _ := m.Client.GetChannel(data.ChannelId, "") teamid = m.GetChannelTeamId(data.ChannelId)
teamid = result.Data.(*model.ChannelData).Channel.TeamId
rmsg.Raw.Data["team_id"] = teamid rmsg.Raw.Data["team_id"] = teamid
} }
if teamid != "" { if teamid != "" {
@ -374,6 +373,19 @@ func (m *MMClient) GetChannelId(name string, teamId string) string {
return "" return ""
} }
func (m *MMClient) GetChannelTeamId(id string) string {
m.RLock()
defer m.RUnlock()
for _, t := range append(m.OtherTeams, m.Team) {
for _, channel := range append(*t.Channels, *t.MoreChannels...) {
if channel.Id == id {
return channel.TeamId
}
}
}
return ""
}
func (m *MMClient) GetChannelHeader(channelId string) string { func (m *MMClient) GetChannelHeader(channelId string) string {
m.RLock() m.RLock()
defer m.RUnlock() defer m.RUnlock()