From 9fa3497f4a76001b744774a8cbe675013e8ce8c6 Mon Sep 17 00:00:00 2001 From: Matthieu Foucault Date: Wed, 16 Sep 2020 12:03:29 -0700 Subject: [PATCH 1/2] Exclude msteams_session.json from git --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index e3ba009ec2..66e6825847 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ # Exclude configuration file matterbridge.toml + +# Exclude session file created by MSTeams bridge +msteams_session.json \ No newline at end of file From 89f3abecf6fa2d953957e7ad1b347940fd50e7e5 Mon Sep 17 00:00:00 2001 From: Matthieu Foucault Date: Wed, 16 Sep 2020 17:34:24 -0700 Subject: [PATCH 2/2] MSTeam bridge sends replies with [thread] indicator --- bridge/msteams/msteams.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/bridge/msteams/msteams.go b/bridge/msteams/msteams.go index 4d4acc2ab1..12eaab5fe1 100644 --- a/bridge/msteams/msteams.go +++ b/bridge/msteams/msteams.go @@ -118,6 +118,16 @@ func (b *Bmsteams) sendReply(msg config.Message) (string, error) { return *res.ID, nil } +func (b *Bmsteams) getReplies(channel string, msg msgraph.ChatMessage) ([]msgraph.ChatMessage, error) { + ct := b.gc.Teams().ID(b.GetString("TeamID")).Channels().ID(channel).Messages().ID(*msg.ID).Replies().Request() + rct, err := ct.Get(b.ctx) + if err != nil { + return nil, err + } + b.Log.Debugf("got %#v replies", len(rct)) + return rct, nil +} + func (b *Bmsteams) getMessages(channel string) ([]msgraph.ChatMessage, error) { ct := b.gc.Teams().ID(b.GetString("TeamID")).Channels().ID(channel).Messages().Request() rct, err := ct.Get(b.ctx) @@ -125,6 +135,13 @@ func (b *Bmsteams) getMessages(channel string) ([]msgraph.ChatMessage, error) { return nil, err } b.Log.Debugf("got %#v messages", len(rct)) + for _, msg := range rct { + replyct, replyerr := b.getReplies(channel, msg) + if replyerr != nil { + return nil, replyerr + } + rct = append(rct, replyct...) + } return rct, nil } @@ -192,6 +209,10 @@ func (b *Bmsteams) poll(channelName string) error { Extra: make(map[string][]interface{}), } + if msg.ReplyToID != nil { + rmsg.ParentID = *msg.ReplyToID + } + b.handleAttachments(&rmsg, msg) b.Log.Debugf("<= Message is %#v", rmsg) b.Remote <- rmsg