fix: send EOSE when ids list is empty in subscriptions

Fixes: https://todo.sr.ht/~gheartsfield/nostr-rs-relay/50
This commit is contained in:
Greg Heartsfield 2022-11-19 10:35:00 -06:00
parent 4de7490d97
commit 5fa24bc9f1

View File

@ -435,7 +435,7 @@ fn query_from_filter(f: &ReqFilter) -> (String, Vec<Box<dyn ToSql>>) {
return (empty_query, empty_params); 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 // query parameters for SQLite
let mut params: Vec<Box<dyn ToSql>> = vec![]; let mut params: Vec<Box<dyn ToSql>> = vec![];
@ -511,8 +511,14 @@ fn query_from_filter(f: &ReqFilter) -> (String, Vec<Box<dyn ToSql>>) {
} }
} }
} }
let id_clause = format!("({})", id_searches.join(" OR ")); if idvec.len() > 0 {
filter_components.push(id_clause); 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 // Query for tags
if let Some(map) = &f.tags { if let Some(map) = &f.tags {