mirror of
https://git.ondrovo.com/MightyPork/group-actor.git
synced 2024-11-21 15:41:03 +00:00
Merge branch 'master' of fgaz/group-actor into master
This commit is contained in:
commit
cbd3c0a575
2 changed files with 9 additions and 7 deletions
|
@ -666,13 +666,15 @@ mod tests {
|
|||
assert!(!group.is_banned("piggo@piggo.space"), "user not banned by default");
|
||||
|
||||
group.ban_user("piggo@piggo.space", true).unwrap();
|
||||
assert!(group.is_member("piggo@piggo.space"), "still member even if banned");
|
||||
assert!(!group.is_member("piggo@piggo.space"), "banned user is kicked");
|
||||
assert!(group.is_banned("piggo@piggo.space"), "banned user is banned");
|
||||
|
||||
assert!(!group.can_write("piggo@piggo.space"), "banned member can't post");
|
||||
|
||||
// unban
|
||||
group.ban_user("piggo@piggo.space", false).unwrap();
|
||||
assert!(!group.can_write("piggo@piggo.space"), "unbanned member is still kicked");
|
||||
group.set_member("piggo@piggo.space", true).unwrap();
|
||||
assert!(group.can_write("piggo@piggo.space"), "un-ban works");
|
||||
}
|
||||
|
||||
|
|
12
src/utils.rs
12
src/utils.rs
|
@ -19,8 +19,8 @@ impl<V, E: Error> LogError for Result<V, E> {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn acct_to_server(acct: &str) -> Option<&str> {
|
||||
acct.trim_start_matches('@').split('@').nth(1)
|
||||
pub(crate) fn acct_to_server(acct: &str) -> Option<String> {
|
||||
acct.trim_start_matches('@').split('@').nth(1).map(|s| s.to_lowercase())
|
||||
}
|
||||
|
||||
pub(crate) fn normalize_acct(acct: &str, group: &str) -> Result<String, GroupError> {
|
||||
|
@ -45,8 +45,8 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_acct_to_server() {
|
||||
assert_eq!(Some("novak"), acct_to_server("pepa@novak"));
|
||||
assert_eq!(Some("banana.co.uk"), acct_to_server("@pepa@banana.co.uk"));
|
||||
assert_eq!(Some("novak".to_string()), acct_to_server("pepa@novak"));
|
||||
assert_eq!(Some("banana.co.uk".to_string()), acct_to_server("@pepa@banana.co.uk"));
|
||||
assert_eq!(None, acct_to_server("probably_local"));
|
||||
}
|
||||
|
||||
|
@ -82,11 +82,11 @@ mod test {
|
|||
);
|
||||
assert_eq!(
|
||||
Ok("piggo@piggo.space".into()),
|
||||
normalize_acct("piGGgo@pIggo.spaCe", "uhh")
|
||||
normalize_acct("piGGo@pIggo.spaCe", "uhh")
|
||||
);
|
||||
assert_eq!(
|
||||
Ok("piggo@banana.nana".into()),
|
||||
normalize_acct("piGGgo", "foo@baNANA.nana")
|
||||
normalize_acct("piGGo", "foo@baNANA.nana")
|
||||
);
|
||||
assert_eq!(Err(GroupError::BadConfig("_".into())), normalize_acct("piggo", "uhh"));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue