From 5fa24bc9f11cd5d11a28d5cff1b0da7798c3dfe3 Mon Sep 17 00:00:00 2001 From: Greg Heartsfield Date: Sat, 19 Nov 2022 10:35:00 -0600 Subject: [PATCH] fix: send EOSE when ids list is empty in subscriptions Fixes: https://todo.sr.ht/~gheartsfield/nostr-rs-relay/50 --- src/db.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/db.rs b/src/db.rs index a8f2ee2..c367e63 100644 --- a/src/db.rs +++ b/src/db.rs @@ -435,7 +435,7 @@ fn query_from_filter(f: &ReqFilter) -> (String, Vec>) { return (empty_query, empty_params); } - let mut query = "SELECT DISTINCT(e.content), e.created_at FROM event e ".to_owned(); + let mut query = "SELECT DISTINCT(e.content), e.created_at FROM event e".to_owned(); // query parameters for SQLite let mut params: Vec> = vec![]; @@ -511,8 +511,14 @@ fn query_from_filter(f: &ReqFilter) -> (String, Vec>) { } } } - let id_clause = format!("({})", id_searches.join(" OR ")); - filter_components.push(id_clause); + if idvec.len() > 0 { + let id_clause = format!("({})", id_searches.join(" OR ")); + filter_components.push(id_clause); + } else { + // if the ids list was empty, we should never return + // any results. + filter_components.push("false".to_owned()); + } } // Query for tags if let Some(map) = &f.tags {