aboutsummaryrefslogtreecommitdiffstats
path: root/src/config.rs
diff options
context:
space:
mode:
authoralyx <alyx@aleteoryx.me>2024-04-03 11:57:23 -0400
committeralyx <alyx@aleteoryx.me>2024-04-03 11:57:23 -0400
commit5a97731c6996847e335daf1fe9a5d265540de3d1 (patch)
tree04b5221411c76e637dd75ee22723b3deb7cd066f /src/config.rs
parentd69f7fc08c491817358d944ab8177152d3afea19 (diff)
downloadlfm_embed-5a97731c6996847e335daf1fe9a5d265540de3d1.tar.gz
lfm_embed-5a97731c6996847e335daf1fe9a5d265540de3d1.tar.bz2
lfm_embed-5a97731c6996847e335daf1fe9a5d265540de3d1.zip
whitelist -> allowlist
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs15
1 files changed, 8 insertions, 7 deletions
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<str>,
pub(crate) theme_debug: bool,
- pub(crate) whitelist: BTreeSet<String>,
- pub(crate) whitelist_mode: String,
+ pub(crate) allowlist: BTreeSet<String>,
+ 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
})
}