Skip to content

Commit

Permalink
Only initiate backfill when it's enabled
Browse files Browse the repository at this point in the history
Fixes #34
  • Loading branch information
twouters committed Sep 19, 2023
1 parent b963030 commit adcf299
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions user.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,15 +406,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})
Expand Down

0 comments on commit adcf299

Please sign in to comment.