khatru: AllowDeleting hook (falls back to just checking direct authorship).
This commit is contained in:
+1
-1
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user