diff --git a/config/config.go b/config/config.go index 86600cb..b55db4b 100644 --- a/config/config.go +++ b/config/config.go @@ -79,6 +79,7 @@ type appConfig struct { HeartbeatMaxAge string `yaml:"heartbeat_max_age" default:"4320h" env:"WAKAPI_HEARTBEAT_MAX_AGE"` 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 AvatarURLTemplate string `yaml:"avatar_url_template" default:"api/avatar/{username_hash}.svg" env:"WAKAPI_AVATAR_URL_TEMPLATE"` SupportContact string `yaml:"support_contact" default:"hostmaster@wakapi.dev" env:"WAKAPI_SUPPORT_CONTACT"` CustomLanguages map[string]string `yaml:"custom_languages"` diff --git a/services/housekeeping.go b/services/housekeeping.go index 7550750..5535bce 100644 --- a/services/housekeeping.go +++ b/services/housekeeping.go @@ -66,6 +66,10 @@ func (s *HousekeepingService) Schedule() { func (s *HousekeepingService) CleanUserDataBefore(user *models.User, before time.Time) error { logbuch.Warn("cleaning up user data for '%s' older than %v", user.ID, before) + if s.config.App.DataCleanupDryRun { + logbuch.Info("skipping actual data deletion for '%v', because this is just a dry run", user.ID) + return nil + } // clear old heartbeats if err := s.heartbeatSrvc.DeleteByUserBefore(user, before); err != nil {