Skip to content

Commit

Permalink
Add option to disable backfilling in big guilds
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Apr 16, 2023
1 parent ed020c4 commit 533054b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type BridgeConfig struct {
Initial BackfillLimitPart `yaml:"initial"`
Missed BackfillLimitPart `yaml:"missed"`
} `yaml:"forward_limits"`
MaxGuildMembers int `yaml:"max_guild_members"`
} `yaml:"backfill"`

Encryption bridgeconfig.EncryptionConfig `yaml:"encryption"`
Expand Down
1 change: 1 addition & 0 deletions config/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func DoUpgrade(helper *up.Helper) {
helper.Copy(up.Int, "bridge", "backfill", "forward_limits", "initial", "channel")
helper.Copy(up.Int, "bridge", "backfill", "forward_limits", "missed", "dm")
helper.Copy(up.Int, "bridge", "backfill", "forward_limits", "missed", "channel")
helper.Copy(up.Int, "bridge", "backfill", "max_guild_members")
helper.Copy(up.Bool, "bridge", "encryption", "allow")
helper.Copy(up.Bool, "bridge", "encryption", "default")
helper.Copy(up.Bool, "bridge", "encryption", "require")
Expand Down
5 changes: 5 additions & 0 deletions example-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ bridge:
# Optional extra text sent when joining a management room.
additional_help: ""

# Settings for backfilling messages.
backfill:
# Limits for forward backfilling.
forward_limits:
Expand All @@ -202,6 +203,10 @@ bridge:
missed:
dm: 0
channel: 0
# Maximum members in a guild to enable backfilling. Set to -1 to disable limit.
# This can be used as a rough heuristic to disable backfilling in channels that are too active.
# Currently only applies to missed message backfill.
max_guild_members: -1

# End-to-bridge encryption support options.
#
Expand Down
4 changes: 3 additions & 1 deletion user.go
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,9 @@ func (user *User) handleGuild(meta *discordgo.Guild, timestamp time.Time, isInSp
}
} else {
portal.UpdateInfo(user, ch)
portal.ForwardBackfillMissed(user, ch)
if user.bridge.Config.Bridge.Backfill.MaxGuildMembers < 0 || meta.MemberCount < user.bridge.Config.Bridge.Backfill.MaxGuildMembers {
portal.ForwardBackfillMissed(user, ch)
}
}
}
}
Expand Down

0 comments on commit 533054b

Please sign in to comment.