From 98d14512c15a514a99a8ce2aee002969a2c8d17b Mon Sep 17 00:00:00 2001 From: naskya Date: Sun, 16 Jun 2024 19:33:55 +0900 Subject: [PATCH] chore (backend-rs): move same process outside of a loop --- .../src/service/antenna/check_hit.rs | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/backend-rs/src/service/antenna/check_hit.rs b/packages/backend-rs/src/service/antenna/check_hit.rs index ed751e1a8c..794b2f794e 100644 --- a/packages/backend-rs/src/service/antenna/check_hit.rs +++ b/packages/backend-rs/src/service/antenna/check_hit.rs @@ -57,14 +57,15 @@ pub(super) async fn check_hit_antenna( return Ok(false); } } else if antenna.src == AntennaSrc::Instances { - let is_from_one_of_specified_servers = antenna.instances.iter().any(|host| { - host.to_ascii_lowercase() - == note_author - .host - .clone() - .unwrap_or_else(|| CONFIG.host.clone()) - .to_ascii_lowercase() - }); + let note_author_host = note_author + .host + .clone() + .unwrap_or_else(|| CONFIG.host.clone()) + .to_ascii_lowercase(); + let is_from_one_of_specified_servers = antenna + .instances + .iter() + .any(|host| host.to_ascii_lowercase() == note_author_host); if !is_from_one_of_specified_servers { return Ok(false); @@ -116,7 +117,10 @@ pub(super) async fn check_hit_antenna( return Ok(false); } - if [NoteVisibility::Home, NoteVisibility::Followers].contains(¬e.visibility) { + if matches!( + note.visibility, + NoteVisibility::Home | NoteVisibility::Followers + ) { let following_user_ids: Vec = if let Some(ids) = cache::get_one(cache::Category::Follow, &antenna.user_id).await? { ids