forked from coracle/nostrlib
upgrade interfaces, add local filtering for subscriptions and some other things I forgot. also a README with examples.
This commit is contained in:
@@ -2,6 +2,8 @@ package filter
|
||||
|
||||
import "github.com/fiatjaf/go-nostr/event"
|
||||
|
||||
type EventFilters []EventFilter
|
||||
|
||||
type EventFilter struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
Kind *int `json:"kind,omitempty"`
|
||||
@@ -11,6 +13,16 @@ type EventFilter struct {
|
||||
Since uint32 `json:"since,omitempty"`
|
||||
}
|
||||
|
||||
func (eff EventFilters) Match(event *event.Event) bool {
|
||||
for _, filter := range eff {
|
||||
if filter.Matches(event) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (ef EventFilter) Matches(event *event.Event) bool {
|
||||
if event == nil {
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user