feat: config to gate all statistics behind login (#99)

* feat: gate all stats behind login

* docs: add config reference for login gate
This commit is contained in:
Gabe Farrell 2025-11-20 22:50:15 -05:00 committed by GitHub
parent c77481fd59
commit daa1bb2456
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 192 additions and 128 deletions

View file

@ -47,6 +47,7 @@ const (
IMPORT_AFTER_UNIX_ENV = "KOITO_IMPORT_AFTER_UNIX"
FETCH_IMAGES_DURING_IMPORT_ENV = "KOITO_FETCH_IMAGES_DURING_IMPORT"
ARTIST_SEPARATORS_ENV = "KOITO_ARTIST_SEPARATORS_REGEX"
LOGIN_GATE_ENV = "KOITO_LOGIN_GATE"
)
type config struct {
@ -83,6 +84,7 @@ type config struct {
importBefore time.Time
importAfter time.Time
artistSeparators []*regexp.Regexp
loginGate bool
}
var (
@ -204,6 +206,10 @@ func loadConfig(getenv func(string) string, version string) (*config, error) {
cfg.artistSeparators = []*regexp.Regexp{regexp.MustCompile(`\s+·\s+`)}
}
if strings.ToLower(getenv(LOGIN_GATE_ENV)) == "true" {
cfg.loginGate = true
}
switch strings.ToLower(getenv(LOG_LEVEL_ENV)) {
case "debug":
cfg.logLevel = 0
@ -409,3 +415,9 @@ func ArtistSeparators() []*regexp.Regexp {
defer lock.RUnlock()
return globalConfig.artistSeparators
}
func LoginGate() bool {
lock.RLock()
defer lock.RUnlock()
return globalConfig.loginGate
}