From 385d43c0aabc047efe8cf5f4f4543b30caadbf3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Fri, 27 Aug 2021 00:43:06 +0200 Subject: [PATCH] improve account lookup --- CHANGELOG.md | 3 +++ Cargo.lock | 2 +- Cargo.toml | 2 +- src/group_handler/handle_mention.rs | 15 ++++++--------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb67330..c2dfe61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## v0.2.4 +- make account lookup try harder + ## v0.2.3 - `/add user` will now try to follow even if already a member diff --git a/Cargo.lock b/Cargo.lock index a650262..0999925 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -328,7 +328,7 @@ checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" [[package]] name = "fedigroups" -version = "0.2.3" +version = "0.2.4" dependencies = [ "anyhow", "clap", diff --git a/Cargo.toml b/Cargo.toml index b5fb06d..6195eb9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fedigroups" -version = "0.2.3" +version = "0.2.4" authors = ["Ondřej Hruška "] edition = "2018" publish = false diff --git a/src/group_handler/handle_mention.rs b/src/group_handler/handle_mention.rs index b8beef4..48661c9 100644 --- a/src/group_handler/handle_mention.rs +++ b/src/group_handler/handle_mention.rs @@ -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) } } }