mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-09 21:29:06 -05:00
feat: add until
for request filters
This implements an additional filter criteria for selecting events prior to some timestamp. See https://github.com/fiatjaf/nostr/issues/39x
This commit is contained in:
parent
0e288fe678
commit
100f890284
|
@ -229,6 +229,12 @@ fn query_from_sub(sub: &Subscription) -> String {
|
||||||
let created_clause = format!("created_at > {}", f.since.unwrap());
|
let created_clause = format!("created_at > {}", f.since.unwrap());
|
||||||
filter_components.push(created_clause);
|
filter_components.push(created_clause);
|
||||||
}
|
}
|
||||||
|
// Query for timestamp
|
||||||
|
if f.until.is_some() {
|
||||||
|
let until_clause = format!("created_at < {}", f.until.unwrap());
|
||||||
|
filter_components.push(until_clause);
|
||||||
|
}
|
||||||
|
|
||||||
// combine all clauses, and add to filter_clauses
|
// combine all clauses, and add to filter_clauses
|
||||||
if !filter_components.is_empty() {
|
if !filter_components.is_empty() {
|
||||||
let mut fc = "( ".to_owned();
|
let mut fc = "( ".to_owned();
|
||||||
|
|
|
@ -29,6 +29,8 @@ pub struct ReqFilter {
|
||||||
pub pubkey: Option<String>,
|
pub pubkey: Option<String>,
|
||||||
/// Events published after this time
|
/// Events published after this time
|
||||||
pub since: Option<u64>,
|
pub since: Option<u64>,
|
||||||
|
/// Events published before this time
|
||||||
|
pub until: Option<u64>,
|
||||||
/// List of author public keys
|
/// List of author public keys
|
||||||
pub authors: Option<Vec<String>>,
|
pub authors: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user