diff options
author | Wim <wim@42.be> | 2017-08-30 14:01:17 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2017-08-30 14:01:17 +0200 |
commit | 9e03fcf1625aa7072ea5177b8a5d318b6f2995cd (patch) | |
tree | 106ded07ec4e1ed97e18edb674f3b7c8b2978592 | |
parent | 8d4521c1df2a734594082d1a376fa6b784bea7c7 (diff) | |
download | matterbridge-msglm-9e03fcf1625aa7072ea5177b8a5d318b6f2995cd.tar.gz matterbridge-msglm-9e03fcf1625aa7072ea5177b8a5d318b6f2995cd.tar.bz2 matterbridge-msglm-9e03fcf1625aa7072ea5177b8a5d318b6f2995cd.zip |
Fix private channel joining bug (mattermost). Closes #248
-rw-r--r-- | bridge/mattermost/mattermost.go | 7 | ||||
-rw-r--r-- | matterclient/matterclient.go | 12 |
2 files changed, 15 insertions, 4 deletions
diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go index 6bc1ebb7..fc4fdb96 100644 --- a/bridge/mattermost/mattermost.go +++ b/bridge/mattermost/mattermost.go @@ -2,6 +2,7 @@ package bmattermost import ( "errors" + "fmt" "github.com/42wim/matterbridge/bridge/config" "github.com/42wim/matterbridge/matterclient" "github.com/42wim/matterbridge/matterhook" @@ -132,7 +133,11 @@ func (b *Bmattermost) Disconnect() error { func (b *Bmattermost) JoinChannel(channel config.ChannelInfo) error { // we can only join channels using the API if b.Config.WebhookURL == "" && b.Config.WebhookBindAddress == "" { - return b.mc.JoinChannel(b.mc.GetChannelId(channel.Name, "")) + id := b.mc.GetChannelId(channel.Name, "") + if id == "" { + return fmt.Errorf("Could not find channel ID for channel %s", channel.Name) + } + return b.mc.JoinChannel(id) } return nil } diff --git a/matterclient/matterclient.go b/matterclient/matterclient.go index f6b942aa..d52a428d 100644 --- a/matterclient/matterclient.go +++ b/matterclient/matterclient.go @@ -481,7 +481,7 @@ func (m *MMClient) JoinChannel(channelId string) error { m.log.Debug("Joining ", channelId) _, resp := m.Client.AddChannelMember(channelId, m.User.Id) if resp.Error != nil { - return errors.New("failed to join") + return resp.Error } return nil } @@ -812,13 +812,19 @@ func (m *MMClient) initUser() error { for _, user := range mmusers { usermap[user.Id] = user } + t := &Team{Team: team, Users: usermap, Id: team.Id} - mmchannels, resp := m.Client.GetPublicChannelsForTeam(team.Id, 0, 5000, "") + mmchannels, resp := m.Client.GetChannelsForTeamForUser(team.Id, m.User.Id, "") if resp.Error != nil { - return errors.New(resp.Error.DetailedError) + return resp.Error } t.Channels = mmchannels + mmchannels, resp = m.Client.GetPublicChannelsForTeam(team.Id, 0, 5000, "") + if resp.Error != nil { + return resp.Error + } + t.MoreChannels = mmchannels m.OtherTeams = append(m.OtherTeams, t) if team.Name == m.Credentials.Team { m.Team = t |