Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions envvars.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
- LOG_ARCHIVER_URI
- ONESHOT
- PRODUCTION_MODE
- RETENTION_PERIOD_DAYS
- MAIN_BOT_TOKEN
- DISCORD_PROXY_URL
15 changes: 8 additions & 7 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package config
import "github.com/caarlos0/env/v6"

type Config struct {
DatabaseUri string `env:"DB_URI"`
LogArchiverUri string `env:"LOG_ARCHIVER_URI"`
OneShot bool `env:"ONESHOT"`
ProductionMode bool `env:"PRODUCTION_MODE" envDefault:"false"`
SentryDsn string `env:"SENTRY_DSN"`
MainBotToken string `env:"MAIN_BOT_TOKEN"`
DiscordProxyUrl string `env:"DISCORD_PROXY_URL"`
DatabaseUri string `env:"DB_URI"`
LogArchiverUri string `env:"LOG_ARCHIVER_URI"`
OneShot bool `env:"ONESHOT"`
ProductionMode bool `env:"PRODUCTION_MODE" envDefault:"false"`
RetentionPeriodDays int `env:"RETENTION_PERIOD_DAYS" envDefault:"30"`
SentryDsn string `env:"SENTRY_DSN"`
MainBotToken string `env:"MAIN_BOT_TOKEN"`
DiscordProxyUrl string `env:"DISCORD_PROXY_URL"`
}

func Parse() (conf Config) {
Expand Down
5 changes: 2 additions & 3 deletions pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import (
const (
BreakTime = time.Second

RetentionPeriod = time.Hour * 24 * 28

// Without this the status poll below has no exit of its own.
purgeTimeout = 5 * time.Minute

Expand Down Expand Up @@ -48,7 +46,8 @@ func (d *Daemon) Run() {
d.logger.Info("Starting run...")

ctx := context.Background()
guildIds, err := d.database.GuildLeaveTime.GetBefore(ctx, RetentionPeriod)
retentionPeriod := time.Duration(d.config.RetentionPeriodDays) * 24 * time.Hour
guildIds, err := d.database.GuildLeaveTime.GetBefore(ctx, retentionPeriod)
if err != nil {
d.logger.Error("Error while fetching guild ids", zap.Error(err))
return
Expand Down
Loading