From 0f20068910e17545bf87e2505f3cde9ac55a1966 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Wed, 6 Dec 2023 02:57:16 -0600 Subject: [PATCH] Only respond with requested tagged events --- src/lib.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index de0b2dd..a19a8f7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,7 +7,7 @@ pub(crate) use crate::nostr::{ use crate::{db::delete_nwc_request, nostr::NOSTR_QUEUE_10}; use crate::{db::get_nwc_events, nostr::NOSTR_QUEUE_7}; use crate::{db::handle_nwc_event, nostr::get_nip11_response}; -use ::nostr::{ClientMessage, Event, EventId, Filter, Kind, RelayMessage, SubscriptionId}; +use ::nostr::{ClientMessage, Event, EventId, Filter, Kind, RelayMessage, SubscriptionId, Tag}; use futures::StreamExt; use futures_util::lock::Mutex; use serde::{Deserialize, Serialize}; @@ -547,6 +547,16 @@ pub async fn handle_filter( events.extend(found_events); } + // if the filter is only requesting replies to a certain event filter to only those + if let Some(event_ids) = filter.events { + events.retain(|event| { + event + .tags + .iter() + .any(|t| matches!(t, Tag::Event(id, _, _) if event_ids.contains(id))) + }) + } + if events.is_empty() { return Ok(vec![]); }