diff --git a/.gitignore b/.gitignore index 8191bb0..199b1ed 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ config.yaml slack logs/ -mautrix-slack.db +*.db* registration.yaml diff --git a/go.mod b/go.mod index 3ed25f7..f1aadd7 100644 --- a/go.mod +++ b/go.mod @@ -32,4 +32,4 @@ require ( maunium.net/go/mauflag v1.0.0 // indirect ) -replace github.com/slack-go/slack => github.com/beeper/slackgo v0.0.0-20230529112042-04e062c05e8b +replace github.com/slack-go/slack => github.com/beeper/slackgo v0.11.3-0.20230919144304-36e35976c9c3 diff --git a/go.sum b/go.sum index 559e75b..a45c495 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,6 @@ github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= -github.com/beeper/slackgo v0.0.0-20230529112042-04e062c05e8b h1:SCBqU2C4ka1BZigu025aZGsTL62oJdlQFRWmzE/nWXg= -github.com/beeper/slackgo v0.0.0-20230529112042-04e062c05e8b/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw= +github.com/beeper/slackgo v0.11.3-0.20230919144304-36e35976c9c3 h1:jtszdZhFmxxstuHffDZ3r5SKtRQ4uHanv8+ODgCmArc= +github.com/beeper/slackgo v0.11.3-0.20230919144304-36e35976c9c3/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw= github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/user.go b/user.go index 1227c7d..66d6f84 100644 --- a/user.go +++ b/user.go @@ -365,6 +365,10 @@ func (user *User) LogoutUserTeam(userTeam *database.UserTeam) error { } } + if _, err := userTeam.Client.SendAuthSignout(); err != nil { + user.log.Errorfln("Failed to send auth.signout request to Slack! %v", err) + } + userTeam.Client = nil user.BridgeStates[userTeam.Key.TeamID].Send(status.BridgeState{StateEvent: status.StateLoggedOut}) @@ -404,15 +408,17 @@ func (user *User) slackMessageHandler(userTeam *database.UserTeam) { userTeam.Upsert() user.tryAutomaticDoublePuppeting(userTeam) - user.BridgeStates[userTeam.Key.TeamID].Send(status.BridgeState{StateEvent: status.StateBackfilling}) - user.log.Infofln("connected to team %s as %s", userTeam.TeamName, userTeam.SlackEmail) - portals := user.bridge.dbPortalsToPortals(user.bridge.DB.Portal.GetAllForUserTeam(userTeam.Key)) - for _, portal := range portals { - err := portal.ForwardBackfill() - if err != nil { - user.log.Warnfln("Forward backfill for portal %s failed: %v", portal.Key, err) + if user.bridge.Config.Bridge.Backfill.Enable { + user.BridgeStates[userTeam.Key.TeamID].Send(status.BridgeState{StateEvent: status.StateBackfilling}) + + portals := user.bridge.dbPortalsToPortals(user.bridge.DB.Portal.GetAllForUserTeam(userTeam.Key)) + for _, portal := range portals { + err := portal.ForwardBackfill() + if err != nil { + user.log.Warnfln("Forward backfill for portal %s failed: %v", portal.Key, err) + } } } user.BridgeStates[userTeam.Key.TeamID].Send(status.BridgeState{StateEvent: status.StateConnected})