1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Enforce a minimum refresh interval for the HIBP module

This commit is contained in:
Chris Cummer 2019-06-22 15:38:03 -07:00
parent 8ce2242b52
commit c75f00cb12

View File

@ -9,8 +9,8 @@ import (
) )
const ( const (
defaultTitle = "HIBP" defaultTitle = "HIBP"
minRefreshSecs = 21600 // TODO: Finish implementing this minRefreshInterval = 21600 // Six hours
) )
type colors struct { type colors struct {
@ -40,6 +40,12 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
settings.colors.ok = ymlConfig.UString("colors.ok", "green") settings.colors.ok = ymlConfig.UString("colors.ok", "green")
settings.colors.pwned = ymlConfig.UString("colors.pwned", "red") settings.colors.pwned = ymlConfig.UString("colors.pwned", "red")
// HIBP data doesn't need to be reloaded very often so to be gentle on this API we
// enforce a minimum refresh interval
if settings.common.RefreshInterval < minRefreshInterval {
settings.common.RefreshInterval = minRefreshInterval
}
return &settings return &settings
} }