Skip to content

Commit c0d0940

Browse files
authored
Merge pull request #54 from fiatjaf/fix/personal-author-filter
Return no events when personal relay author filter excludes the authed user
2 parents 1cf789a + 1a4faf7 commit c0d0940

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

personal/relay.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"iter"
77
"net/http"
8+
"slices"
89

910
"fiatjaf.com/nostr"
1011
"fiatjaf.com/nostr/khatru"
@@ -157,7 +158,12 @@ func query(ctx context.Context, filter nostr.Filter) iter.Seq[nostr.Event] {
157158
}
158159
}
159160

160-
// otherwise add the authenticated user to the filter so that is enforced
161+
// otherwise constrain the filter to the authenticated user's own events.
162+
// if the client asked for specific authors, only honor it when it includes
163+
// the authed user, so we never return events that don't match the request
164+
if len(filter.Authors) > 0 && !slices.Contains(filter.Authors, authed) {
165+
return func(yield func(nostr.Event) bool) {}
166+
}
161167
filter.Authors = []nostr.PubKey{authed}
162168
return db.QueryEvents(filter, global.Settings.Limits.MaxQueryLimit)
163169
}

0 commit comments

Comments
 (0)