From 5a97731c6996847e335daf1fe9a5d265540de3d1 Mon Sep 17 00:00:00 2001 From: alyx Date: Wed, 3 Apr 2024 11:57:23 -0400 Subject: whitelist -> allowlist --- src/config.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index bc24b83..1a192b2 100644 --- a/src/config.rs +++ b/src/config.rs @@ -24,10 +24,10 @@ pub struct Config { pub(crate) theme_ext: Arc, pub(crate) theme_debug: bool, - pub(crate) whitelist: BTreeSet, - pub(crate) whitelist_mode: String, + pub(crate) allowlist: BTreeSet, + pub(crate) allowlist_mode: String, pub(crate) default_refresh: Duration, - pub(crate) whitelist_refresh: Duration, + pub(crate) allowlist_refresh: Duration, } impl Config { @@ -35,6 +35,7 @@ impl Config { let duration_from_var = |v: &str, d: u64| -> Duration {var(v).map(|r| ds::parse(&r).expect("bad duration string")).unwrap_or_else(|_| Duration::from_secs(d))}; let default_refresh = duration_from_var("LFME_DEFAULT_REFRESH", 300); let whitelist_refresh = duration_from_var("LFME_WHITELIST_REFRESH", 60); + let allowlist_refresh = if whitelist_refresh == Duration::from_secs(60) { duration_from_var("LFME_ALLOWLIST_REFRESH", 60) } else { whitelist_refresh }; Arc::new(Config { lastfm_api_key: var("LFME_LASTFM_API_KEY").expect("last.fm API key must be set").into(), google_api_key: var("LFME_GOOGLE_API_KEY").map(Into::into).ok(), @@ -47,10 +48,10 @@ impl Config { theme_ext: var("LFME_THEME_EXT").unwrap_or_else(|_| ".hbs".into()).into(), theme_debug: var("LFME_THEME_DEV").map(|h| &h == "1").unwrap_or(false), - whitelist: var("LFME_WHITELIST").ok().map(|w| w.split(',').map(|s| s.trim().to_string()).collect()).unwrap_or_default(), - whitelist_mode: var("LFME_WHITELIST_MODE").map(|m| m.to_ascii_lowercase()).unwrap_or_else(|_| "open".into()), - default_refresh: default_refresh + Duration::from_secs(1), - whitelist_refresh: whitelist_refresh + Duration::from_secs(1) + allowlist: var("LFME_WHITELIST").or_else(|_| var("LFME_ALLOWLIST")).ok().map(|w| w.split(',').map(|s| s.trim().to_string()).collect()).unwrap_or_default(), + allowlist_mode: var("LFME_WHITELIST_MODE").or_else(|_| var("LFME_ALLOWLIST_MODE")).map(|m| m.to_ascii_lowercase()).unwrap_or_else(|_| "open".into()), + default_refresh: default_refresh, + allowlist_refresh: allowlist_refresh }) } -- cgit v1.2.3-54-g00ecf