4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-06-26 13:09:24 +00:00

Add support for mattermost threading (#627)

This commit is contained in:
Patrick Connolly
2019-01-09 15:50:03 -05:00
committed by Wim
parent 5193634a52
commit b33b50987b
3 changed files with 12 additions and 11 deletions

View File

@ -104,6 +104,7 @@ func (b *Bmattermost) handleMatterClient(messages chan *config.Message) {
Channel: message.Channel,
Text: message.Text,
ID: message.Post.Id,
ParentID: message.Post.ParentId,
Extra: make(map[string][]interface{}),
}
@ -163,7 +164,7 @@ func (b *Bmattermost) handleUploadFile(msg *config.Message) (string, error) {
if b.GetBool("PrefixMessagesWithNick") {
msg.Text = msg.Username + msg.Text
}
res, err = b.mc.PostMessageWithFiles(channelID, msg.Text, []string{id})
res, err = b.mc.PostMessageWithFiles(channelID, msg.Text, msg.ParentID, []string{id})
}
return res, err
}

View File

@ -124,7 +124,7 @@ func (b *Bmattermost) Send(msg config.Message) (string, error) {
// Upload a file if it exists
if msg.Extra != nil {
for _, rmsg := range helper.HandleExtra(&msg, b.General) {
if _, err := b.mc.PostMessage(b.mc.GetChannelId(rmsg.Channel, b.TeamID), rmsg.Username+rmsg.Text); err != nil {
if _, err := b.mc.PostMessage(b.mc.GetChannelId(rmsg.Channel, b.TeamID), rmsg.Username+rmsg.Text, msg.ParentID); err != nil {
b.Log.Errorf("PostMessage failed: %s", err)
}
}
@ -144,5 +144,5 @@ func (b *Bmattermost) Send(msg config.Message) (string, error) {
}
// Post normal message
return b.mc.PostMessage(b.mc.GetChannelId(msg.Channel, b.TeamID), msg.Text)
return b.mc.PostMessage(b.mc.GetChannelId(msg.Channel, b.TeamID), msg.Text, msg.ParentID)
}