summaryrefslogtreecommitdiffstats
path: root/matterclient/matterclient.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-06-12 20:30:30 +0200
committerWim <wim@42.be>2017-06-12 20:30:30 +0200
commit860a371eebdf378822f9cd246447272186c46dea (patch)
treeac3abda4ad7b0c2e582dbf88e80a680093082163 /matterclient/matterclient.go
parent41a46526a1eb858e74de153e7da0e538c26617f0 (diff)
downloadmatterbridge-msglm-860a371eebdf378822f9cd246447272186c46dea.tar.gz
matterbridge-msglm-860a371eebdf378822f9cd246447272186c46dea.tar.bz2
matterbridge-msglm-860a371eebdf378822f9cd246447272186c46dea.zip
Use cache for teamid
Diffstat (limited to 'matterclient/matterclient.go')
-rw-r--r--matterclient/matterclient.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/matterclient/matterclient.go b/matterclient/matterclient.go
index 859c94bc..43446bcb 100644
--- a/matterclient/matterclient.go
+++ b/matterclient/matterclient.go
@@ -295,8 +295,7 @@ func (m *MMClient) parseActionPost(rmsg *Message) {
// edit messsages have no team_id for some reason
if teamid == "" {
// we can find the team_id from the channelid
- result, _ := m.Client.GetChannel(data.ChannelId, "")
- teamid = result.Data.(*model.ChannelData).Channel.TeamId
+ teamid = m.GetChannelTeamId(data.ChannelId)
rmsg.Raw.Data["team_id"] = teamid
}
if teamid != "" {
@@ -374,6 +373,19 @@ func (m *MMClient) GetChannelId(name string, teamId string) string {
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 {
m.RLock()
defer m.RUnlock()