improve /add user

pull/14/head v0.2.3
Ondřej Hruška 3 years ago
parent 957f0dbb3b
commit 674b9da6fa
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 3
      CHANGELOG.md
  2. 2
      Cargo.lock
  3. 2
      Cargo.toml
  4. 9
      src/group_handler/handle_mention.rs

@ -1,5 +1,8 @@
# Changelog # Changelog
## v0.2.3
- `/add user` will now try to follow even if already a member
## v0.2.2 ## v0.2.2
- All hashtags, server names and handles are now lowercased = case-insensitive - All hashtags, server names and handles are now lowercased = case-insensitive
- Prevent the `-a` flag overwriting existing group in the config - Prevent the `-a` flag overwriting existing group in the config

2
Cargo.lock generated

@ -328,7 +328,7 @@ checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
[[package]] [[package]]
name = "fedigroups" name = "fedigroups"
version = "0.2.2" version = "0.2.3"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"clap", "clap",

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

@ -379,7 +379,6 @@ impl<'a> ProcessMention<'a> {
async fn cmd_add_member(&mut self, user: &str) -> Result<(), GroupError> { async fn cmd_add_member(&mut self, user: &str) -> Result<(), GroupError> {
let u = normalize_acct(user, &self.group_acct)?; let u = normalize_acct(user, &self.group_acct)?;
if self.is_admin { if self.is_admin {
if !self.config.is_member(&u) {
match self.config.set_member(&u, true) { match self.config.set_member(&u, true) {
Ok(_) => { Ok(_) => {
self.add_reply(format!("User {} added to the group!", u)); self.add_reply(format!("User {} added to the group!", u));
@ -390,9 +389,6 @@ impl<'a> ProcessMention<'a> {
self.add_reply(format!("Failed to add user {} to group: {}", u, e)); self.add_reply(format!("Failed to add user {} to group: {}", u, e));
} }
} }
} else {
debug!("User was already a member");
}
} else { } else {
self.add_reply("Only admins can manage members"); self.add_reply("Only admins can manage members");
} }
@ -402,7 +398,6 @@ impl<'a> ProcessMention<'a> {
async fn cmd_remove_member(&mut self, user: &str) -> Result<(), GroupError> { async fn cmd_remove_member(&mut self, user: &str) -> Result<(), GroupError> {
let u = normalize_acct(user, &self.group_acct)?; let u = normalize_acct(user, &self.group_acct)?;
if self.is_admin { if self.is_admin {
if self.config.is_member(&u) {
match self.config.set_member(&u, false) { match self.config.set_member(&u, false) {
Ok(_) => { Ok(_) => {
self.add_reply(format!("User {} removed from the group.", u)); self.add_reply(format!("User {} removed from the group.", u));
@ -413,7 +408,6 @@ impl<'a> ProcessMention<'a> {
unreachable!() unreachable!()
} }
} }
}
} else { } else {
self.add_reply("Only admins can manage members"); self.add_reply("Only admins can manage members");
} }
@ -586,10 +580,11 @@ impl<'a> ProcessMention<'a> {
// admin can leave but that's a bad idea // admin can leave but that's a bad idea
let _ = self.config.set_member(&self.status_acct, false); let _ = self.config.set_member(&self.status_acct, false);
self.add_reply("You're no longer a group member. Unfollow the group user to stop receiving group messages."); self.add_reply("You're no longer a group member. Unfollow the group user to stop receiving group messages.");
}
self.unfollow_user_by_id(&self.status_user_id).await self.unfollow_user_by_id(&self.status_user_id).await
.log_error("Failed to unfollow"); .log_error("Failed to unfollow");
} }
}
async fn cmd_join(&mut self) { async fn cmd_join(&mut self) {
if self.config.is_member_or_admin(&self.status_acct) { if self.config.is_member_or_admin(&self.status_acct) {

Loading…
Cancel
Save