khatru: AllowDeleting hook (falls back to just checking direct authorship).

This commit is contained in:
fiatjaf
2026-05-26 22:57:12 -03:00
parent 8bc1d8ce7f
commit 05237b3463
2 changed files with 2 additions and 1 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ func (rl *Relay) handleDeleteRequest(ctx context.Context, evt nostr.Event) error
errg, ctx := errgroup.WithContext(ctx)
for target := range rl.QueryStored(ctx, f) {
// got the event, now check if the user can delete it
if target.PubKey == evt.PubKey {
if rl.AllowDeleting == nil && target.PubKey == evt.PubKey || rl.AllowDeleting != nil && rl.AllowDeleting(ctx, target, evt) {
// delete it
errg.Go(func() error {
if err := rl.DeleteEvent(ctx, target.ID); err != nil {
+1
View File
@@ -75,6 +75,7 @@ type Relay struct {
DeleteEvent func(ctx context.Context, id nostr.ID) error
OnEventSaved func(ctx context.Context, event nostr.Event)
OnEventDeleted func(ctx context.Context, deleted nostr.Event)
AllowDeleting func(ctx context.Context, target, deletion nostr.Event) bool
OnEphemeralEvent func(ctx context.Context, event nostr.Event)
OnRequest func(ctx context.Context, filter nostr.Filter) (reject bool, msg string)
OnCount func(ctx context.Context, filter nostr.Filter) (reject bool, msg string)