remove event from expiration manager if it is deleted.

This commit is contained in:
fiatjaf 2025-04-03 23:11:47 -03:00
parent 2bb6d4d29a
commit c9a7d60543
2 changed files with 16 additions and 0 deletions

View File

@ -67,6 +67,9 @@ func (rl *Relay) handleDeleteRequest(ctx context.Context, evt *nostr.Event) erro
return err
}
}
// if it was tracked to be expired that is not needed anymore
rl.expirationManager.removeEvent(target.ID)
} else {
// fail and stop here
return fmt.Errorf("blocked: %s", msg)

View File

@ -134,3 +134,16 @@ func (em *expirationManager) trackEvent(evt *nostr.Event) {
em.mu.Unlock()
}
}
func (em *expirationManager) removeEvent(id string) {
em.mu.Lock()
defer em.mu.Unlock()
// Find and remove the event from the heap
for i := 0; i < len(em.events); i++ {
if em.events[i].id == id {
heap.Remove(&em.events, i)
break
}
}
}