feat: implement queue pruning and message rotation
All checks were successful
check / check (push) Successful in 1m2s

Enforce QUEUE_MAX_AGE and MAX_HISTORY config values that previously
existed but were not applied. The existing cleanup loop now also:

- Prunes client_queues entries older than QUEUE_MAX_AGE (default 48h)
- Rotates messages per target (channel/DM) beyond MAX_HISTORY (default 10000)
- Removes orphaned messages no longer referenced by any client queue

closes #40
This commit is contained in:
user
2026-03-10 03:20:21 -07:00
parent f287fdf6d1
commit 6f6ea33eaa
4 changed files with 196 additions and 8 deletions

View File

@@ -40,6 +40,7 @@ type Config struct {
SentryDSN string
MaxHistory int
MaxMessageSize int
QueueMaxAge int
MOTD string
ServerName string
FederationKey string
@@ -70,6 +71,7 @@ func New(
viper.SetDefault("METRICS_PASSWORD", "")
viper.SetDefault("MAX_HISTORY", "10000")
viper.SetDefault("MAX_MESSAGE_SIZE", "4096")
viper.SetDefault("QUEUE_MAX_AGE", "172800")
viper.SetDefault("MOTD", defaultMOTD)
viper.SetDefault("SERVER_NAME", "")
viper.SetDefault("FEDERATION_KEY", "")
@@ -94,6 +96,7 @@ func New(
MetricsPassword: viper.GetString("METRICS_PASSWORD"),
MaxHistory: viper.GetInt("MAX_HISTORY"),
MaxMessageSize: viper.GetInt("MAX_MESSAGE_SIZE"),
QueueMaxAge: viper.GetInt("QUEUE_MAX_AGE"),
MOTD: viper.GetString("MOTD"),
ServerName: viper.GetString("SERVER_NAME"),
FederationKey: viper.GetString("FEDERATION_KEY"),