File tree Expand file tree Collapse file tree 4 files changed +19
-6
lines changed Expand file tree Collapse file tree 4 files changed +19
-6
lines changed Original file line number Diff line number Diff line change 33
33
* nostr: ensure that NIP-59 rumor has ` EventId ` ([ Yuki Kishimoto] )
34
34
* nostr: update ` PartialEvent ` methods ([ Yuki Kishimoto] )
35
35
* nostr: change ` EventBuilder::award_badge ` fingerprint ([ Yuki Kishimoto] )
36
+ * nostr: add NIP-50 support to ` Filter::match_event ` method ([ Yuki Kishimoto] )
36
37
* pool: take mutex ownership instead of clone in ` InternalRelayPool::get_events_from ` ([ Yuki Kishimoto] )
37
38
* pool: remove IDs collection from ` InternalRelayPool::get_events_from ` ([ Yuki Kishimoto] )
38
39
* pool: better checks before perform queries or send messages to relays ([ Yuki Kishimoto] )
Original file line number Diff line number Diff line change @@ -406,8 +406,7 @@ impl Filter {
406
406
}
407
407
408
408
/// Determine if `Filter` match given `Event`.
409
- ///
410
- /// The `search` filed is not supported yet!
409
+ #[ inline]
411
410
pub fn match_event ( & self , event : & Event ) -> bool {
412
411
self . inner . match_event ( event. deref ( ) )
413
412
}
Original file line number Diff line number Diff line change @@ -449,8 +449,7 @@ impl JsFilter {
449
449
}
450
450
451
451
/// Determine if `Filter` match given `Event`.
452
- ///
453
- /// The `search` filed is not supported yet!
452
+ #[ inline]
454
453
#[ wasm_bindgen( js_name = matchEvent) ]
455
454
pub fn match_event ( & self , event : & JsEvent ) -> bool {
456
455
self . inner . match_event ( event. deref ( ) )
Original file line number Diff line number Diff line change @@ -745,9 +745,18 @@ impl Filter {
745
745
} )
746
746
}
747
747
748
+ #[ inline]
749
+ fn search_match ( & self , event : & Event ) -> bool {
750
+ match & self . search {
751
+ Some ( query) => event
752
+ . content
753
+ . split_whitespace ( )
754
+ . any ( |word| word. eq_ignore_ascii_case ( query) ) ,
755
+ None => true ,
756
+ }
757
+ }
758
+
748
759
/// Determine if [Filter] match given [Event].
749
- ///
750
- /// The `search` field is not supported yet!
751
760
#[ inline]
752
761
pub fn match_event ( & self , event : & Event ) -> bool {
753
762
self . ids_match ( event)
@@ -756,6 +765,7 @@ impl Filter {
756
765
&& self . since . map_or ( true , |t| event. created_at >= t)
757
766
&& self . until . map_or ( true , |t| event. created_at <= t)
758
767
&& self . tag_match ( event)
768
+ && self . search_match ( event)
759
769
}
760
770
}
761
771
@@ -1109,6 +1119,10 @@ mod tests {
1109
1119
let filter: Filter = Filter :: new ( ) . hashtag ( "this-should-not-match" ) ;
1110
1120
assert ! ( !filter. match_event( & event) ) ;
1111
1121
assert ! ( !filter. match_event( & event_with_empty_tags) ) ;
1122
+
1123
+ // Test match search
1124
+ let filter: Filter = Filter :: new ( ) . search ( "test" ) . into ( ) ;
1125
+ assert ! ( filter. match_event( & event) ) ;
1112
1126
}
1113
1127
}
1114
1128
You can’t perform that action at this time.
0 commit comments