upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/client.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-07-18 14:37:53 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2024-07-18 14:37:53 +0100
commit48ae8d19337954e54101a7e3bd9597c0c9a6b970 (patch)
treeb1c0108e30e835819b0c35277729476b3c71158f /src/client.rs
parent580756e0b4bec3f24e6d25ab5bc7ed4536325d17 (diff)
fix(fetch): dont report old profile as update
as any profile event was being recorded as a update
Diffstat (limited to 'src/client.rs')
-rw-r--r--src/client.rs21
1 files changed, 14 insertions, 7 deletions
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(
1023 }) 1023 })
1024} 1024}
1025 1025
1026#[allow(clippy::too_many_lines)]
1026async fn process_fetched_events( 1027async fn process_fetched_events(
1027 events: Vec<nostr::Event>, 1028 events: Vec<nostr::Event>,
1028 request: &FetchRequest, 1029 request: &FetchRequest,
@@ -1102,14 +1103,20 @@ async fn process_fetched_events(
1102 fresh_profiles.insert(event.author()); 1103 fresh_profiles.insert(event.author());
1103 } 1104 }
1104 } else if [Kind::RelayList, Kind::Metadata].contains(&event.kind()) { 1105 } else if [Kind::RelayList, Kind::Metadata].contains(&event.kind()) {
1105 if Kind::Metadata.eq(&event.kind()) { 1106 if request
1106 if request 1107 .missing_contributor_profiles
1107 .missing_contributor_profiles 1108 .contains(event.author_ref())
1108 .contains(event.author_ref()) 1109 {
1110 report.contributor_profiles.insert(event.author());
1111 } else if let Some((_, (metadata_timestamp, relay_list_timestamp))) = request
1112 .profiles_to_fetch_from_user_relays
1113 .get_key_value(event.author_ref())
1114 {
1115 if (Kind::Metadata.eq(&event.kind())
1116 && event.created_at().gt(metadata_timestamp))
1117 || (Kind::RelayList.eq(&event.kind())
1118 && event.created_at().gt(relay_list_timestamp))
1109 { 1119 {
1110 report.contributor_profiles.insert(event.author());
1111 } else {
1112 // TODO: how do we know if the recieved profile is new?
1113 report.profile_updates.insert(event.author()); 1120 report.profile_updates.insert(event.author());
1114 } 1121 }
1115 } 1122 }