2 Commits
Author SHA1 Message Date
MightyPork 385d43c0aa improve account lookup 2021-08-27 00:43:06 +02:00
MightyPork 674b9da6fa improve /add user 2021-08-27 00:30:49 +02:00
4 changed files with 33 additions and 35 deletions
+6
View File
@@ -1,5 +1,11 @@
# Changelog
## v0.2.4
- make account lookup try harder
## v0.2.3
- `/add user` will now try to follow even if already a member
## v0.2.2
- All hashtags, server names and handles are now lowercased = case-insensitive
- Prevent the `-a` flag overwriting existing group in the config
Generated
+1 -1
View File
@@ -328,7 +328,7 @@ checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
[[package]]
name = "fedigroups"
version = "0.2.2"
version = "0.2.4"
dependencies = [
"anyhow",
"clap",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "fedigroups"
version = "0.2.2"
version = "0.2.4"
authors = ["Ondřej Hruška <ondra@ondrovo.com>"]
edition = "2018"
publish = false
+25 -33
View File
@@ -46,21 +46,18 @@ impl<'a> ProcessMention<'a> {
Err(e.into())
}
Ok(Ok(res)) => {
debug!("Result: {:#?}", res);
if let Some(item) = res.accounts.into_iter().next() {
for item in res.accounts {
let acct_normalized = normalize_acct(&item.acct, &self.group_acct)?;
if acct_normalized == acct {
debug!("Search done, account found: {}", item.acct);
Ok(Some(item.id))
return Ok(Some(item.id))
} else {
warn!("Search done but found wrong account: {}", item.acct);
Ok(None)
warn!("Found wrong account: {}", item.acct);
}
} else {
debug!("Search done, nothing found");
Ok(None)
}
debug!("Search done, nothing found");
Ok(None)
}
}
}
@@ -379,19 +376,15 @@ impl<'a> ProcessMention<'a> {
async fn cmd_add_member(&mut self, user: &str) -> Result<(), GroupError> {
let u = normalize_acct(user, &self.group_acct)?;
if self.is_admin {
if !self.config.is_member(&u) {
match self.config.set_member(&u, true) {
Ok(_) => {
self.add_reply(format!("User {} added to the group!", u));
self.follow_by_acct(&u)
.await.log_error("Failed to follow");
}
Err(e) => {
self.add_reply(format!("Failed to add user {} to group: {}", u, e));
}
match self.config.set_member(&u, true) {
Ok(_) => {
self.add_reply(format!("User {} added to the group!", u));
self.follow_by_acct(&u)
.await.log_error("Failed to follow");
}
Err(e) => {
self.add_reply(format!("Failed to add user {} to group: {}", u, e));
}
} else {
debug!("User was already a member");
}
} else {
self.add_reply("Only admins can manage members");
@@ -402,16 +395,14 @@ impl<'a> ProcessMention<'a> {
async fn cmd_remove_member(&mut self, user: &str) -> Result<(), GroupError> {
let u = normalize_acct(user, &self.group_acct)?;
if self.is_admin {
if self.config.is_member(&u) {
match self.config.set_member(&u, false) {
Ok(_) => {
self.add_reply(format!("User {} removed from the group.", u));
self.unfollow_by_acct(&u).await
.log_error("Failed to unfollow removed user");
}
Err(_) => {
unreachable!()
}
match self.config.set_member(&u, false) {
Ok(_) => {
self.add_reply(format!("User {} removed from the group.", u));
self.unfollow_by_acct(&u).await
.log_error("Failed to unfollow removed user");
}
Err(_) => {
unreachable!()
}
}
} else {
@@ -586,9 +577,10 @@ impl<'a> ProcessMention<'a> {
// admin can leave but that's a bad idea
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.unfollow_user_by_id(&self.status_user_id).await
.log_error("Failed to unfollow");
}
self.unfollow_user_by_id(&self.status_user_id).await
.log_error("Failed to unfollow");
}
async fn cmd_join(&mut self) {