Skip to content

Commit

Permalink
Only respond with requested tagged events
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Dec 6, 2023
1 parent fffef50 commit 0f20068
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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![]);
}
Expand Down

0 comments on commit 0f20068

Please sign in to comment.