notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 243f6cecd738833cdef5500e5e02b204ba12d618
parent 95c836b375384297bc121754f7812c165c9268ce
Author: William Casarin <jb55@jb55.com>
Date:   Wed,  7 Feb 2024 12:06:38 -0800

add enostr->nostrdb filter conversions

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Asrc/filter.rs | 37+++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+), 0 deletions(-)

diff --git a/src/filter.rs b/src/filter.rs @@ -0,0 +1,37 @@ +impl From<enostr::Filter> for nostrdb::Filter {} + fn from(filter: enostr::Filter) -> Self { + let mut nfilter = nostrdb::Filter::new(); + + if let Some(ids) = filter.ids { + nfilter.ids(ids) + } + + if let Some(authors) = filter.authors { + nfilter.authors(authors) + } + + if let Some(kinds) = filter.kinds { + nfilter.kinds(kinds) + } + + // #e + if let Some(events) = filter.events { + nfilter.tags(events, 'e') + } + + // #p + if let Some(pubkeys) = filter.pubkeys { + nfilter.pubkeys(pubkeys) + } + + if let Some(since) = filter.since { + nfilter.since(since) + } + + if let Some(limit) = filter.limit { + nfilter.limit(limit) + } + + nfilter + } +}