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 # 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 ## v0.4.3
- Fix hashtag not working in a mention - Fix hashtag not working in a mention

2
Cargo.lock generated

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

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

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

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

@ -445,7 +445,7 @@ impl GroupConfig {
/// Check if the user's server is banned /// Check if the user's server is banned
fn is_users_server_banned(&self, acct: &str) -> bool { fn is_users_server_banned(&self, acct: &str) -> bool {
let server = acct_to_server(acct); 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 { pub(crate) fn can_write(&self, acct: &str) -> bool {
@ -561,8 +561,8 @@ impl GroupConfig {
} }
} }
fn acct_to_server(acct: &str) -> &str { fn acct_to_server(acct: &str) -> String {
acct.split('@').nth(1).unwrap_or_default() crate::utils::acct_to_server(acct).unwrap_or_default()
} }
#[cfg(test)] #[cfg(test)]
@ -581,9 +581,9 @@ mod tests {
#[test] #[test]
fn test_acct_to_server() { fn test_acct_to_server() {
assert_eq!("pikachu.rocks", acct_to_server("raichu@pikachu.rocks")); assert_eq!("pikachu.rocks".to_string(), acct_to_server("raichu@pikachu.rocks"));
assert_eq!("pikachu.rocks", acct_to_server("m@pikachu.rocks")); assert_eq!("pikachu.rocks".to_string(), acct_to_server("m@pikachu.rocks"));
assert_eq!("", acct_to_server("what")); assert_eq!("".to_string(), acct_to_server("what"));
} }
#[test] #[test]

Loading…
Cancel
Save