Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

commit 0a84323fd997761d0a82251b4bc018c91c22208c Author: Joona Hoikkala <joohoi@users.noreply.github.com> Date: Sun Jun 16 17:23:50 2019 +0000 Add an option to skip the Mattermost server version check (#849) Adds SkipVersionCheck bool option for mattermost diff --git a/bridge/config/config.go b/bridge/config/config.go index a0cc20f..e7d8da5 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -1276 +1277 @@ type Protocol struct {   ShowUserTyping bool // slack   ShowEmbeds bool // discord   SkipTLSVerify bool // IRC, mattermost + SkipVersionCheck bool // mattermost   StripNick bool // all protocols   SyncTopic bool // slack   TengoModifyMessage string // general diff --git a/bridge/mattermost/helpers.go b/bridge/mattermost/helpers.go index 121cd4d..14b7469 100644 --- a/bridge/mattermost/helpers.go +++ b/bridge/mattermost/helpers.go @@ -706 +707 @@ func (b *Bmattermost) apiLogin() error {   b.mc.SetLogLevel("debug")   }   b.mc.SkipTLSVerify = b.GetBool("SkipTLSVerify") + b.mc.SkipVersionCheck = b.GetBool("SkipVersionCheck")   b.mc.NoTLS = b.GetBool("NoTLS")   b.Log.Infof("Connecting %s (team: %s) on %s", b.GetString("Login"), b.GetString("Team"), b.GetString("Server"))   err := b.mc.Login() diff --git a/matterclient/helpers.go b/matterclient/helpers.go index c3d3314..d5b1038 100644 --- a/matterclient/helpers.go +++ b/matterclient/helpers.go @@ -18615 +18619 @@ func (m *MMClient) serverAlive(firstConnection bool, b *backoff.Backoff) error {   if resp.Error != nil {   return fmt.Errorf("%#v", resp.Error.Error())   } - if firstConnection && !supportedVersion(resp.ServerVersion) { + if firstConnection && !m.SkipVersionCheck && !supportedVersion(resp.ServerVersion) {   return fmt.Errorf("unsupported mattermost version: %s", resp.ServerVersion)   } - m.ServerVersion = resp.ServerVersion - if m.ServerVersion == "" { - m.logger.Debugf("Server not up yet, reconnecting in %s", d) - time.Sleep(d) + if !m.SkipVersionCheck { + m.ServerVersion = resp.ServerVersion + if m.ServerVersion == "" { + m.logger.Debugf("Server not up yet, reconnecting in %s", d) + time.Sleep(d) + } else { + m.logger.Infof("Found version %s", m.ServerVersion) + return nil + }   } else { - m.logger.Infof("Found version %s", m.ServerVersion)   return nil   }   } diff --git a/matterclient/matterclient.go b/matterclient/matterclient.go index 66ffcca..338f86d 100644 --- a/matterclient/matterclient.go +++ b/matterclient/matterclient.go @@ -1614 +1615 @@ import (  )    type Credentials struct { - Login string - Team string - Pass string - Token string - CookieToken bool - Server string - NoTLS bool - SkipTLSVerify bool + Login string + Team string + Pass string + Token string + CookieToken bool + Server string + NoTLS bool + SkipTLSVerify bool + SkipVersionCheck bool  }    type Message struct {