feat: gate all status behind login

This commit is contained in:
Gabe Farrell 2025-11-20 22:43:06 -05:00
parent 6a53fca8f3
commit f469db5a28
6 changed files with 189 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
}