summaryrefslogtreecommitdiffstats
path: root/bridge
diff options
context:
space:
mode:
authorWim <wim@42.be>2020-04-21 19:29:24 +0200
committerGitHub <noreply@github.com>2020-04-21 19:29:24 +0200
commitd99c54343a8e097a8503854cff8b0d74ca7f9c3e (patch)
treeac81e3b5ea8c59164adc4746c70343f5eb4a1507 /bridge
parent308a1100006e6e5b3d6cb5dcea90ac7a9d95b594 (diff)
downloadmatterbridge-msglm-d99c54343a8e097a8503854cff8b0d74ca7f9c3e.tar.gz
matterbridge-msglm-d99c54343a8e097a8503854cff8b0d74ca7f9c3e.tar.bz2
matterbridge-msglm-d99c54343a8e097a8503854cff8b0d74ca7f9c3e.zip
Remove panics and retry polling on failure (msteams). Fixes #1104 (#1105)
Diffstat (limited to 'bridge')
-rw-r--r--bridge/msteams/msteams.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/bridge/msteams/msteams.go b/bridge/msteams/msteams.go
index b3540d08..be0cd88f 100644
--- a/bridge/msteams/msteams.go
+++ b/bridge/msteams/msteams.go
@@ -71,7 +71,15 @@ func (b *Bmsteams) Disconnect() error {
}
func (b *Bmsteams) JoinChannel(channel config.ChannelInfo) error {
- go b.poll(channel.Name)
+ go func(name string) {
+ for {
+ err := b.poll(name)
+ if err != nil {
+ b.Log.Errorf("polling failed for %s: %s. retrying in 5 seconds", name, err)
+ }
+ time.Sleep(time.Second * 5)
+ }
+ }(channel.Name)
return nil
}
@@ -120,12 +128,12 @@ func (b *Bmsteams) getMessages(channel string) ([]msgraph.ChatMessage, error) {
}
//nolint:gocognit
-func (b *Bmsteams) poll(channelName string) {
+func (b *Bmsteams) poll(channelName string) error {
msgmap := make(map[string]time.Time)
b.Log.Debug("getting initial messages")
res, err := b.getMessages(channelName)
if err != nil {
- panic(err)
+ return err
}
for _, msg := range res {
msgmap[*msg.ID] = *msg.CreatedDateTime
@@ -138,7 +146,7 @@ func (b *Bmsteams) poll(channelName string) {
for {
res, err := b.getMessages(channelName)
if err != nil {
- panic(err)
+ return err
}
for i := len(res) - 1; i >= 0; i-- {
msg := res[i]