From 44f43bc4ddd20e3935ba915fee8f5a6573f77cee Mon Sep 17 00:00:00 2001 From: Wim Date: Fri, 29 Mar 2019 21:30:26 +0100 Subject: [PATCH] Reconnect on expired session (rocketchat) --- bridge/rocketchat/rocketchat.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bridge/rocketchat/rocketchat.go b/bridge/rocketchat/rocketchat.go index 59f0e99c..51920d27 100644 --- a/bridge/rocketchat/rocketchat.go +++ b/bridge/rocketchat/rocketchat.go @@ -169,6 +169,15 @@ func (b *Brocketchat) Send(msg config.Message) (string, error) { rmsg, err := b.c.SendMessage(smsg) if rmsg == nil { + if strings.Contains(err.Error(), "Invalid or expired session, please login again") || + strings.Contains(err.Error(), "error-invalid-user") { + b.Log.Info("Login expired, reconnecting..") + err = b.apiLogin() + if err != nil { + return "", err + } + b.Remote <- config.Message{Username: "system", Text: "rejoin", Channel: "", Account: b.Account, Event: config.EventRejoinChannels} + } return "", err } return rmsg.ID, err