summaryrefslogtreecommitdiffstats
path: root/bridge/mattermost
diff options
context:
space:
mode:
authorWim <wim@42.be>2020-12-31 16:59:47 +0100
committerGitHub <noreply@github.com>2020-12-31 16:59:47 +0100
commit19d47784bde7f5d8cfc06f868350ed6ac69c8a21 (patch)
tree74aba773ce82e7db12182c3554d62e9602b84f95 /bridge/mattermost
parentb89102c5fcb96c5c40ca3d2ed673b6deefe92e64 (diff)
downloadmatterbridge-msglm-19d47784bde7f5d8cfc06f868350ed6ac69c8a21.tar.gz
matterbridge-msglm-19d47784bde7f5d8cfc06f868350ed6ac69c8a21.tar.bz2
matterbridge-msglm-19d47784bde7f5d8cfc06f868350ed6ac69c8a21.zip
Add threading support with token (discord) (#1342)
Webhooks don't support the threading yet, so this is token only. In discord you can reply on each message of a thread, but this is not possible in mattermost (so some changes added there to make sure we always answer on the rootID of the thread). Also needs some more testing with slack. update : It now also uses the token when replying to a thread (even if webhooks are enabled), until webhooks have support for threads.
Diffstat (limited to 'bridge/mattermost')
-rw-r--r--bridge/mattermost/handlers.go2
-rw-r--r--bridge/mattermost/mattermost.go9
2 files changed, 10 insertions, 1 deletions
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) {