From 650d9209c3b036512d318cc016f9fd3fd8ce2bad Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Tue, 11 Mar 2025 17:42:27 -0300 Subject: [PATCH] policies: nip70 enforcer. --- policies/events.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/policies/events.go b/policies/events.go index a21e21d..d7d06d5 100644 --- a/policies/events.go +++ b/policies/events.go @@ -8,6 +8,7 @@ import ( "time" "github.com/nbd-wtf/go-nostr" + "github.com/nbd-wtf/go-nostr/nip70" ) // PreventTooManyIndexableTags returns a function that can be used as a RejectFilter that will reject @@ -107,3 +108,10 @@ func PreventTimestampsInTheFuture(threshold time.Duration) func(context.Context, func RejectEventsWithBase64Media(ctx context.Context, evt *nostr.Event) (bool, string) { return strings.Contains(evt.Content, "data:image/") || strings.Contains(evt.Content, "data:video/"), "event with base64 media" } + +func OnlyAllowNIP70ProtectedEvents(ctx context.Context, event *nostr.Event) (reject bool, msg string) { + if nip70.IsProtected(event) { + return false, "" + } + return true, "blocked: we only accept events protected with the nip70 \"-\" tag" +}