From 5389031d8c8c8367e85c9efdfc2472a92541138f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Wed, 2 Nov 2022 09:28:40 +0100 Subject: [PATCH] nobot fix --- CHANGELOG.md | 3 +++ Cargo.toml | 2 +- src/error.rs | 2 ++ src/group_handler/handle_mention.rs | 8 ++++---- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99b5022..17c9d99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # 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 diff --git a/Cargo.toml b/Cargo.toml index 21a0f72..641e9ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fedigroups" -version = "0.4.4" +version = "0.4.5" authors = ["Ondřej Hruška "] edition = "2018" publish = false diff --git a/src/error.rs b/src/error.rs index b103740..aaaa263 100644 --- a/src/error.rs +++ b/src/error.rs @@ -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}")] diff --git a/src/group_handler/handle_mention.rs b/src/group_handler/handle_mention.rs index 3166924..ad1d7a0 100644 --- a/src/group_handler/handle_mention.rs +++ b/src/group_handler/handle_mention.rs @@ -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) + 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 { - let normalized = normalize_acct(&account.acct, &self.group_acct)?; if self.config.is_banned(&normalized) { Err(GroupError::UserIsBanned) } else if self.config.is_optout(&normalized) {