nostr-rs-relay

My dev fork of nostr-rs-relay
git clone git://jb55.com/nostr-rs-relay
Log | Files | Refs | README | LICENSE

commit 100f890284bfbcfa9551f5faf2c7bd904381e9cd
parent 0e288fe678df4dd919be8782341c0c3d28a41240
Author: Greg Heartsfield <scsibug@imap.cc>
Date:   Thu, 23 Dec 2021 21:38:32 -0600

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

Diffstat:
Msrc/db.rs | 6++++++
Msrc/subscription.rs | 2++
2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/db.rs b/src/db.rs @@ -229,6 +229,12 @@ fn query_from_sub(sub: &Subscription) -> String { let created_clause = format!("created_at > {}", f.since.unwrap()); 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 if !filter_components.is_empty() { let mut fc = "( ".to_owned(); diff --git a/src/subscription.rs b/src/subscription.rs @@ -29,6 +29,8 @@ pub struct ReqFilter { pub pubkey: Option<String>, /// Events published after this time pub since: Option<u64>, + /// Events published before this time + pub until: Option<u64>, /// List of author public keys pub authors: Option<Vec<String>>, }