mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-14 23:19:07 -05:00
Filter on additional fields (complete)
This commit is contained in:
parent
753958659d
commit
89d2bcd598
|
@ -122,8 +122,13 @@ impl ReqFilter {
|
||||||
// determine if all populated fields in this filter match the provided event.
|
// determine if all populated fields in this filter match the provided event.
|
||||||
// a filter matches an event if all the populated fields match.
|
// a filter matches an event if all the populated fields match.
|
||||||
// Iterate through each filter field, return false if the field exists and doesn't match the event.
|
// Iterate through each filter field, return false if the field exists and doesn't match the event.
|
||||||
|
// order based on cost; id, time, kind, author, event
|
||||||
if !self.id.as_ref().map(|v| v == &event.id).unwrap_or(true) {
|
if !self.id.as_ref().map(|v| v == &event.id).unwrap_or(true) {
|
||||||
false
|
false
|
||||||
|
} else if !self.since.map(|t| event.created_at > t).unwrap_or(true) {
|
||||||
|
false
|
||||||
|
} else if !self.kind.map(|v| v == event.kind).unwrap_or(true) {
|
||||||
|
false
|
||||||
} else if !self
|
} else if !self
|
||||||
.author
|
.author
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
@ -131,8 +136,6 @@ impl ReqFilter {
|
||||||
.unwrap_or(true)
|
.unwrap_or(true)
|
||||||
{
|
{
|
||||||
false
|
false
|
||||||
} else if !self.kind.map(|v| v == event.kind).unwrap_or(true) {
|
|
||||||
false
|
|
||||||
} else if !self.author_match(&event.pubkey) {
|
} else if !self.author_match(&event.pubkey) {
|
||||||
false
|
false
|
||||||
} else if !self
|
} else if !self
|
||||||
|
@ -142,10 +145,6 @@ impl ReqFilter {
|
||||||
.unwrap_or(true)
|
.unwrap_or(true)
|
||||||
{
|
{
|
||||||
false
|
false
|
||||||
// event: Option<String>,
|
|
||||||
// pubkey: Option<String>,
|
|
||||||
// since: Option<u64>,
|
|
||||||
// authors: Option<Vec<String>>,
|
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user