add server lowercasing also to group_config::acct_to_server()

Ondřej Hruška 3 years ago
parent cbd3c0a575
commit cb6724baab
Signed by untrusted user: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 12
      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]

Loading…
Cancel
Save