simplify event rejection code.

This commit is contained in:
fiatjaf
2023-11-11 18:00:04 -03:00
parent 78dd138ca8
commit 21e0c559f7

View File

@@ -13,22 +13,15 @@ func (rl *Relay) AddEvent(ctx context.Context, evt *nostr.Event) error {
return fmt.Errorf("event is nil")
}
msg := ""
rejecting := false
for _, reject := range rl.RejectEvent {
rejecting, msg = reject(ctx, evt)
if rejecting {
break
if reject, msg := reject(ctx, evt); reject {
if msg == "" {
msg = "no reason"
}
return fmt.Errorf(msg)
}
}
if rejecting {
if msg == "" {
msg = "no reason"
}
return fmt.Errorf(msg)
}
if 20000 <= evt.Kind && evt.Kind < 30000 {
// do not store ephemeral events
} else {