mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-14 23:19:07 -05:00
API for checking if subscription matches key
This commit is contained in:
parent
5bc36cc591
commit
03bc1fab18
|
@ -54,6 +54,11 @@ impl Event {
|
|||
let _e: Event = serde_json::from_str(json)?;
|
||||
Err(Error::EventParseFailed)
|
||||
}
|
||||
|
||||
// check if this event is valid (should be propagated, stored) based on signature.
|
||||
pub fn is_valid(&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::error::{Error, Result};
|
||||
use crate::event::Event;
|
||||
use serde::{Deserialize, Deserializer, Serialize};
|
||||
//use serde_json::json;
|
||||
//use serde_json::Result;
|
||||
|
@ -89,6 +90,23 @@ impl Subscription {
|
|||
pub fn get_filter_count(&self) -> usize {
|
||||
self.filters.len()
|
||||
}
|
||||
pub fn interested_in_event(&self, event: &Event) -> bool {
|
||||
// loop through every filter, and return true if any match this event.
|
||||
for f in self.filters.iter() {
|
||||
if f.interested_in_event(event) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ReqFilter {
|
||||
pub fn interested_in_event(&self, event: &Event) -> bool {
|
||||
// determine if all populated fields in this filter match the provided event.
|
||||
|
||||
todo!();
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Reference in New Issue
Block a user