From abd4d0fc806cd3bbef50d0112939e0d5b8ca8e67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Calder=C3=B3n?= Date: Fri, 11 Oct 2024 12:29:31 -0300 Subject: [PATCH] Discard older gift wrap events (#368) --- src/app.rs | 8 ++++++++ src/util.rs | 2 -- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app.rs b/src/app.rs index bd5a0cdf..fbbc29cb 100644 --- a/src/app.rs +++ b/src/app.rs @@ -69,6 +69,14 @@ pub async fn run( }; let event = unwrap_gift_wrap(&my_keys, &event)?; + // Here we discard messages older than the real since parameter + let since_time = chrono::Utc::now() + .checked_sub_signed(chrono::Duration::minutes(10)) + .unwrap() + .timestamp() as u64; + if event.rumor.created_at.as_u64() < since_time { + continue; + } let message = Message::from_json(&event.rumor.content); match message { diff --git a/src/util.rs b/src/util.rs index c9e0cf22..fb8d1ea1 100644 --- a/src/util.rs +++ b/src/util.rs @@ -208,8 +208,6 @@ pub async fn publish_order( let reputation = get_user_reputation(initiator_pubkey, keys).await?; // We transform the order fields to tags to use in the event let tags = order_to_tags(&new_order_db, reputation); - - info!("order tags to be published: {:#?}", tags); // nip33 kind with order fields as tags and order id as identifier let event = new_event(keys, "", order_id.to_string(), tags)?; info!("Order event to be published: {event:#?}");