From 48ae8d19337954e54101a7e3bd9597c0c9a6b970 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 18 Jul 2024 14:37:53 +0100 Subject: fix(fetch): dont report old profile as update as any profile event was being recorded as a update --- src/client.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/client.rs b/src/client.rs index 4202a8e..4f002fb 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1023,6 +1023,7 @@ async fn create_relays_request( }) } +#[allow(clippy::too_many_lines)] async fn process_fetched_events( events: Vec, request: &FetchRequest, @@ -1102,14 +1103,20 @@ async fn process_fetched_events( fresh_profiles.insert(event.author()); } } else if [Kind::RelayList, Kind::Metadata].contains(&event.kind()) { - if Kind::Metadata.eq(&event.kind()) { - if request - .missing_contributor_profiles - .contains(event.author_ref()) + if request + .missing_contributor_profiles + .contains(event.author_ref()) + { + report.contributor_profiles.insert(event.author()); + } else if let Some((_, (metadata_timestamp, relay_list_timestamp))) = request + .profiles_to_fetch_from_user_relays + .get_key_value(event.author_ref()) + { + if (Kind::Metadata.eq(&event.kind()) + && event.created_at().gt(metadata_timestamp)) + || (Kind::RelayList.eq(&event.kind()) + && event.created_at().gt(relay_list_timestamp)) { - report.contributor_profiles.insert(event.author()); - } else { - // TODO: how do we know if the recieved profile is new? report.profile_updates.insert(event.author()); } } -- cgit v1.2.3