mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-14 23:19:07 -05:00
Check event tag filter
This commit is contained in:
parent
c075194c3d
commit
753958659d
13
src/event.rs
13
src/event.rs
|
@ -56,6 +56,19 @@ impl Event {
|
||||||
pub fn is_valid(&self) -> bool {
|
pub fn is_valid(&self) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
// check if given event is referenced in a tag
|
||||||
|
pub fn event_tag_match(&self, event: &str) -> bool {
|
||||||
|
for t in self.tags.iter() {
|
||||||
|
if t.len() == 2 {
|
||||||
|
if t.get(0).unwrap() == "#e" {
|
||||||
|
if t.get(1).unwrap() == event {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -135,6 +135,13 @@ impl ReqFilter {
|
||||||
false
|
false
|
||||||
} else if !self.author_match(&event.pubkey) {
|
} else if !self.author_match(&event.pubkey) {
|
||||||
false
|
false
|
||||||
|
} else if !self
|
||||||
|
.event
|
||||||
|
.as_ref()
|
||||||
|
.map(|e| event.event_tag_match(e))
|
||||||
|
.unwrap_or(true)
|
||||||
|
{
|
||||||
|
false
|
||||||
// event: Option<String>,
|
// event: Option<String>,
|
||||||
// pubkey: Option<String>,
|
// pubkey: Option<String>,
|
||||||
// since: Option<u64>,
|
// since: Option<u64>,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user