summaryrefslogtreecommitdiffstats
path: root/bridge
diff options
context:
space:
mode:
Diffstat (limited to 'bridge')
-rw-r--r--bridge/discord/discord.go17
-rw-r--r--bridge/discord/handlers.go5
-rw-r--r--bridge/mattermost/handlers.go2
-rw-r--r--bridge/mattermost/mattermost.go9
4 files changed, 30 insertions, 3 deletions
diff --git a/bridge/discord/discord.go b/bridge/discord/discord.go
index d63006a7..c8b810c6 100644
--- a/bridge/discord/discord.go
+++ b/bridge/discord/discord.go
@@ -244,7 +244,7 @@ func (b *Bdiscord) Send(msg config.Message) (string, error) {
// Use webhook to send the message
useWebhooks := b.shouldMessageUseWebhooks(&msg)
- if useWebhooks && msg.Event != config.EventMsgDelete {
+ if useWebhooks && msg.Event != config.EventMsgDelete && msg.ParentID == "" {
return b.handleEventWebhook(&msg, channelID)
}
@@ -287,11 +287,24 @@ func (b *Bdiscord) handleEventBotUser(msg *config.Message, channelID string) (st
return msg.ID, err
}
+ m := discordgo.MessageSend{
+ Content: msg.Username + msg.Text,
+ }
+
+ if msg.ParentID != "" && msg.ParentID != "msg-parent-not-found" {
+ m.Reference = &discordgo.MessageReference{
+ MessageID: msg.ParentID,
+ ChannelID: channelID,
+ GuildID: b.guildID,
+ }
+ }
+
// Post normal message
- res, err := b.c.ChannelMessageSend(channelID, msg.Username+msg.Text)
+ res, err := b.c.ChannelMessageSendComplex(channelID, &m)
if err != nil {
return "", err
}
+
return res.ID, nil
}
diff --git a/bridge/discord/handlers.go b/bridge/discord/handlers.go
index 370b8912..d2b38538 100644
--- a/bridge/discord/handlers.go
+++ b/bridge/discord/handlers.go
@@ -127,6 +127,11 @@ func (b *Bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreat
// Replace emotes
rmsg.Text = replaceEmotes(rmsg.Text)
+ // Add our parent id if it exists
+ if m.MessageReference != nil {
+ rmsg.ParentID = m.MessageReference.MessageID
+ }
+
b.Log.Debugf("<= Sending message from %s on %s to gateway", m.Author.Username, b.Account)
b.Log.Debugf("<= Message is %#v", rmsg)
b.Remote <- rmsg
diff --git a/bridge/mattermost/handlers.go b/bridge/mattermost/handlers.go
index 67e68d02..58af43a8 100644
--- a/bridge/mattermost/handlers.go
+++ b/bridge/mattermost/handlers.go
@@ -108,7 +108,7 @@ func (b *Bmattermost) handleMatterClient(messages chan *config.Message) {
Channel: message.Channel,
Text: message.Text,
ID: message.Post.Id,
- ParentID: message.Post.ParentId,
+ ParentID: message.Post.RootId, // ParentID is obsolete with mattermost
Extra: make(map[string][]interface{}),
}
diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go
index e41b19d7..2c11b79e 100644
--- a/bridge/mattermost/mattermost.go
+++ b/bridge/mattermost/mattermost.go
@@ -127,6 +127,15 @@ func (b *Bmattermost) Send(msg config.Message) (string, error) {
msg.Text = fmt.Sprintf("[thread]: %s", msg.Text)
}
+ // we only can reply to the root of the thread, not to a specific ID (like discord for example does)
+ if msg.ParentID != "" {
+ post, res := b.mc.Client.GetPost(msg.ParentID, "")
+ if res.Error != nil {
+ b.Log.Errorf("getting post %s failed: %s", msg.ParentID, res.Error.DetailedError)
+ }
+ msg.ParentID = post.RootId
+ }
+
// Upload a file if it exists
if msg.Extra != nil {
for _, rmsg := range helper.HandleExtra(&msg, b.General) {