Skip to content

Commit

Permalink
fix: make user cleanup opt-out (see #629)
Browse files Browse the repository at this point in the history
  • Loading branch information
muety committed Mar 30, 2024
1 parent f379e59 commit 2ef4111
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ type appConfig struct {
CountCacheTTLMin int `yaml:"count_cache_ttl_min" default:"30" env:"WAKAPI_COUNT_CACHE_TTL_MIN"`
DataRetentionMonths int `yaml:"data_retention_months" default:"-1" env:"WAKAPI_DATA_RETENTION_MONTHS"`
DataCleanupDryRun bool `yaml:"data_cleanup_dry_run" default:"false" env:"WAKAPI_DATA_CLEANUP_DRY_RUN"` // for debugging only
MaxInactiveMonths int `yaml:"max_inactive_months" default:"12" env:"WAKAPI_MAX_INACTIVE_MONTHS"`
MaxInactiveMonths int `yaml:"max_inactive_months" default:"-1" env:"WAKAPI_MAX_INACTIVE_MONTHS"`
AvatarURLTemplate string `yaml:"avatar_url_template" default:"api/avatar/{username_hash}.svg" env:"WAKAPI_AVATAR_URL_TEMPLATE"`
SupportContact string `yaml:"support_contact" default:"[email protected]" env:"WAKAPI_SUPPORT_CONTACT"`
DateFormat string `yaml:"date_format" default:"Mon, 02 Jan 2006" env:"WAKAPI_DATE_FORMAT"`
Expand Down
3 changes: 3 additions & 0 deletions services/housekeeping.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ func (s *HousekeepingService) runCleanData() {

func (s *HousekeepingService) runCleanInactiveUsers() {
s.queueWorkers.Dispatch(func() {
if s.config.App.MaxInactiveMonths <= 0 {
return
}
if err := s.CleanInactiveUsers(time.Now().AddDate(0, -s.config.App.MaxInactiveMonths, 0)); err != nil {
config.Log().Error("failed to clean up inactive users, %v", err)
}
Expand Down

0 comments on commit 2ef4111

Please sign in to comment.