upgrade interfaces, add local filtering for subscriptions and some other things I forgot. also a README with examples.

This commit is contained in:
fiatjaf
2021-12-16 20:47:53 -03:00
parent 7dfc354eec
commit 0a60285e30
8 changed files with 141 additions and 40 deletions
+12
View File
@@ -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