mirror of
https://github.com/gabehf/Koito.git
synced 2026-03-07 21:48:18 -08:00
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:
parent
c77481fd59
commit
daa1bb2456
7 changed files with 192 additions and 128 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue