diff options
author | Wim <wim@42.be> | 2022-02-06 18:26:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-06 18:26:30 +0100 |
commit | 9c43eff753ec4976f1bd879732915e29c933c5b9 (patch) | |
tree | 790f944b59a64bf664e45479899925e1f8aa1d42 /bridge/mattermost/handlers.go | |
parent | c8d7fdeedcc2fe596055da000bfa8c23c4ba5cab (diff) | |
download | matterbridge-msglm-9c43eff753ec4976f1bd879732915e29c933c5b9.tar.gz matterbridge-msglm-9c43eff753ec4976f1bd879732915e29c933c5b9.tar.bz2 matterbridge-msglm-9c43eff753ec4976f1bd879732915e29c933c5b9.zip |
Add support for using ID in channel config (mattermost) (#1715)
Diffstat (limited to 'bridge/mattermost/handlers.go')
-rw-r--r-- | bridge/mattermost/handlers.go | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/bridge/mattermost/handlers.go b/bridge/mattermost/handlers.go index 00c9445d..c7b51243 100644 --- a/bridge/mattermost/handlers.go +++ b/bridge/mattermost/handlers.go @@ -140,9 +140,14 @@ func (b *Bmattermost) handleMatterClient(messages chan *config.Message) { continue } + channelName := b.getChannelName(message.Post.ChannelId) + if channelName == "" { + channelName = message.Channel + } + // only download avatars if we have a place to upload them (configured mediaserver) if b.General.MediaServerUpload != "" || b.General.MediaDownloadPath != "" { - b.handleDownloadAvatar(message.UserID, message.Channel) + b.handleDownloadAvatar(message.UserID, channelName) } b.Log.Debugf("== Receiving event %#v", message) @@ -150,7 +155,7 @@ func (b *Bmattermost) handleMatterClient(messages chan *config.Message) { rmsg := &config.Message{ Username: message.Username, UserID: message.UserID, - Channel: message.Channel, + Channel: channelName, Text: message.Text, ID: message.Post.Id, ParentID: message.Post.RootId, // ParentID is obsolete with mattermost @@ -197,9 +202,14 @@ func (b *Bmattermost) handleMatterClient6(messages chan *config.Message) { continue } + channelName := b.getChannelName(message.Post.ChannelId) + if channelName == "" { + channelName = message.Channel + } + // only download avatars if we have a place to upload them (configured mediaserver) if b.General.MediaServerUpload != "" || b.General.MediaDownloadPath != "" { - b.handleDownloadAvatar(message.UserID, message.Channel) + b.handleDownloadAvatar(message.UserID, channelName) } b.Log.Debugf("== Receiving event %#v", message) @@ -207,7 +217,7 @@ func (b *Bmattermost) handleMatterClient6(messages chan *config.Message) { rmsg := &config.Message{ Username: message.Username, UserID: message.UserID, - Channel: message.Channel, + Channel: channelName, Text: message.Text, ID: message.Post.Id, ParentID: message.Post.RootId, // ParentID is obsolete with mattermost @@ -248,6 +258,7 @@ func (b *Bmattermost) handleMatterHook(messages chan *config.Message) { for { message := b.mh.Receive() b.Log.Debugf("Receiving from matterhook %#v", message) + messages <- &config.Message{ UserID: message.UserID, Username: message.UserName, @@ -265,7 +276,7 @@ func (b *Bmattermost) handleUploadFile(msg *config.Message) (string, error) { var err error var res, id string - channelID := b.mc.GetChannelId(msg.Channel, b.TeamID) + channelID := b.getChannelID(msg.Channel) for _, f := range msg.Extra["file"] { fi := f.(config.FileInfo) id, err = b.mc.UploadFile(*fi.Data, channelID, fi.Name) @@ -285,7 +296,7 @@ func (b *Bmattermost) handleUploadFile(msg *config.Message) (string, error) { func (b *Bmattermost) handleUploadFile6(msg *config.Message) (string, error) { var err error var res, id string - channelID := b.mc6.GetChannelID(msg.Channel, b.TeamID) + channelID := b.getChannelID(msg.Channel) for _, f := range msg.Extra["file"] { fi := f.(config.FileInfo) id, err = b.mc6.UploadFile(*fi.Data, channelID, fi.Name) |