diff --git a/src/config.rs b/src/config.rs index 53fed8338..1c4d0b0ba 100644 --- a/src/config.rs +++ b/src/config.rs @@ -513,6 +513,11 @@ impl Context { ); self.sql.set_raw_config(key.as_ref(), value).await?; } + Config::Addr => { + self.sql + .set_raw_config(key.as_ref(), value.map(|s| s.to_lowercase()).as_deref()) + .await?; + } _ => { self.sql.set_raw_config(key.as_ref(), value).await?; } @@ -662,6 +667,21 @@ mod tests { ); } + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn test_set_config_addr() { + let t = TestContext::new().await; + + // Test that uppercase address get lowercased. + assert!(t + .set_config(Config::Addr, Some("Foobar@eXample.oRg")) + .await + .is_ok()); + assert_eq!( + t.get_config(Config::Addr).await.unwrap().unwrap(), + "foobar@example.org" + ); + } + /// Tests that "bot" config can only be set to "0" or "1". #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_set_config_bot() {