From cb6724baab4fd65bad7413d1589f09affbf67e50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Tue, 2 Nov 2021 23:48:43 +0100 Subject: [PATCH] add server lowercasing also to group_config::acct_to_server() --- src/store/group_config.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/store/group_config.rs b/src/store/group_config.rs index 08c086b..15fe25c 100644 --- a/src/store/group_config.rs +++ b/src/store/group_config.rs @@ -458,7 +458,7 @@ impl GroupConfig { /// Check if the user's server is banned fn is_users_server_banned(&self, acct: &str) -> bool { let server = acct_to_server(acct); - self.is_server_banned(server) + self.is_server_banned(&server) } pub(crate) fn can_write(&self, acct: &str) -> bool { @@ -574,8 +574,8 @@ impl GroupConfig { } } -fn acct_to_server(acct: &str) -> &str { - acct.split('@').nth(1).unwrap_or_default() +fn acct_to_server(acct: &str) -> String { + crate::utils::acct_to_server(acct).unwrap_or_default() } #[cfg(test)] @@ -594,9 +594,9 @@ mod tests { #[test] fn test_acct_to_server() { - assert_eq!("pikachu.rocks", acct_to_server("raichu@pikachu.rocks")); - assert_eq!("pikachu.rocks", acct_to_server("m@pikachu.rocks")); - assert_eq!("", acct_to_server("what")); + assert_eq!("pikachu.rocks".to_string(), acct_to_server("raichu@pikachu.rocks")); + assert_eq!("pikachu.rocks".to_string(), acct_to_server("m@pikachu.rocks")); + assert_eq!("".to_string(), acct_to_server("what")); } #[test]