improve account lookup

master v0.2.4
Ondřej Hruška 3 years ago
parent 674b9da6fa
commit 385d43c0aa
Signed by untrusted user: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 3
      CHANGELOG.md
  2. 2
      Cargo.lock
  3. 2
      Cargo.toml
  4. 13
      src/group_handler/handle_mention.rs

@ -1,5 +1,8 @@
# Changelog # Changelog
## v0.2.4
- make account lookup try harder
## v0.2.3 ## v0.2.3
- `/add user` will now try to follow even if already a member - `/add user` will now try to follow even if already a member

2
Cargo.lock generated

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

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

@ -46,24 +46,21 @@ impl<'a> ProcessMention<'a> {
Err(e.into()) Err(e.into())
} }
Ok(Ok(res)) => { Ok(Ok(res)) => {
debug!("Result: {:#?}", res); for item in res.accounts {
if let Some(item) = res.accounts.into_iter().next() {
let acct_normalized = normalize_acct(&item.acct, &self.group_acct)?; let acct_normalized = normalize_acct(&item.acct, &self.group_acct)?;
if acct_normalized == acct { if acct_normalized == acct {
debug!("Search done, account found: {}", item.acct); debug!("Search done, account found: {}", item.acct);
Ok(Some(item.id)) return Ok(Some(item.id))
} else { } else {
warn!("Search done but found wrong account: {}", item.acct); warn!("Found wrong account: {}", item.acct);
Ok(None)
} }
} else { }
debug!("Search done, nothing found"); debug!("Search done, nothing found");
Ok(None) Ok(None)
} }
} }
} }
}
fn append_admin_list_to_reply(&mut self) { fn append_admin_list_to_reply(&mut self) {
let mut admins = self.config.get_admins().collect::<Vec<_>>(); let mut admins = self.config.get_admins().collect::<Vec<_>>();

Loading…
Cancel
Save