Update Matches to accept ValidatedEvent; regenerate test fixtures with valid signatures

This commit is contained in:
Jay
2026-05-22 11:41:04 -04:00
parent 17789a7dbd
commit d699feb236
3 changed files with 49 additions and 54 deletions
+7 -6
View File
@@ -249,36 +249,37 @@ func (f *Filter) UnmarshalJSON(data []byte) error {
// Matches returns true if the event satisfies all filter conditions.
// Supports prefix matching for IDs and authors, and tag filtering.
// Does not account for custom extensions.
func Matches(f Filter, event events.Event) bool {
func Matches(f Filter, event events.ValidatedEvent) bool {
// Check ID
if len(f.IDs) > 0 {
if !matchesPrefix(event.ID, f.IDs) {
if !matchesPrefix(event.ID(), f.IDs) {
return false
}
}
// Check Author
if len(f.Authors) > 0 {
if !matchesPrefix(event.PubKey, f.Authors) {
if !matchesPrefix(event.PubKey(), f.Authors) {
return false
}
}
// Check Kind
if len(f.Kinds) > 0 {
if !matchesKinds(event.Kind, f.Kinds) {
if !matchesKinds(event.Kind(), f.Kinds) {
return false
}
}
// Check Timestamp
if !matchesTimeRange(event.CreatedAt, f.Since, f.Until) {
if !matchesTimeRange(event.CreatedAt(), f.Since, f.Until) {
return false
}
// Check Tags
if len(f.Tags) > 0 {
if !matchesTags(event.Tags, &f.Tags) {
tags := event.Tags()
if !matchesTags(tags, &f.Tags) {
return false
}
}