Compare commits

..

6 Commits

  1. 7
      CHANGELOG.md
  2. 2
      Cargo.lock
  3. 2
      Cargo.toml
  4. 2
      src/error.rs
  5. 8
      src/group_handler/handle_mention.rs
  6. 12
      src/store/group_config.rs

@ -1,5 +1,12 @@
# Changelog
## v0.4.5
- Ignore #nobot in bio if the user is also a member
## v0.4.4
- Fix some failing tests
- Lowercase the domain when normalizing an account
## v0.4.3
- Fix hashtag not working in a mention

2
Cargo.lock generated

@ -374,7 +374,7 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
[[package]]
name = "fedigroups"
version = "0.4.3"
version = "0.4.4"
dependencies = [
"anyhow",
"clap",

@ -1,6 +1,6 @@
[package]
name = "fedigroups"
version = "0.4.3"
version = "0.4.5"
authors = ["Ondřej Hruška <ondra@ondrovo.com>"]
edition = "2018"
publish = false

@ -8,6 +8,8 @@ pub enum GroupError {
UserIsBanned,
#[error("User opted out from the group")]
UserOptedOut,
#[error("User opted out from the group using #nobot")]
UserOptedOutNobot,
#[error("Server could not be banned because there are admin users on it")]
AdminsOnServer,
#[error("Config error: {0}")]

@ -773,11 +773,11 @@ impl<'a> ProcessMention<'a> {
// Try to unfollow
let account = self.client.get_account(id).await?;
let bio = utils::strip_html(&account.note);
if RE_NOBOT_TAG.is_match(&bio) {
// #nobot
Err(GroupError::UserOptedOut)
} else {
let normalized = normalize_acct(&account.acct, &self.group_acct)?;
if RE_NOBOT_TAG.is_match(&bio) && !self.config.is_member(&normalized) {
// #nobot in a non-member account
Err(GroupError::UserOptedOutNobot)
} else {
if self.config.is_banned(&normalized) {
Err(GroupError::UserIsBanned)
} else if self.config.is_optout(&normalized) {

@ -445,7 +445,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 {
@ -561,8 +561,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)]
@ -581,9 +581,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