upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-02-23 13:46:57 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-02-23 13:46:57 +0000
commitf19b424e01fc5a682778c5e2bb194d242efd6987 (patch)
tree835551491737b9163d8cc84055b5223662ac156c
parent0c71e191963bec729c3ca13c212b231af7582f06 (diff)
feat: handle deletion of PR/PR-update events from purgatory
Kind 5 deletion events referencing a PR or PR-update event by e-tag now remove the matching purgatory entry, provided the deletion author matches the PR event author. Placeholders (git data arrived before the event) are not removed since they have no author to verify against. PR purgatory is keyed by event ID hex so this is an O(1) lookup, checked before the O(n) announcement and state event scans.
-rw-r--r--src/nostr/policy/deletion.rs24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/nostr/policy/deletion.rs b/src/nostr/policy/deletion.rs
index 01241c9..6457c90 100644
--- a/src/nostr/policy/deletion.rs
+++ b/src/nostr/policy/deletion.rs
@@ -81,9 +81,9 @@ impl DeletionPolicy {
81 } 81 }
82 } 82 }
83 83
84 /// Remove a purgatory entry (announcement or state event) matched by event ID. 84 /// Remove a purgatory entry (announcement, state event, or PR event) matched by event ID.
85 /// 85 ///
86 /// Checks announcements first (kind 30617), then state events (kind 30618). 86 /// Checks in order: announcements (30617), state events (30618), PR/PR-update events.
87 /// Only removes entries whose author matches `author`. 87 /// Only removes entries whose author matches `author`.
88 fn remove_by_event_id( 88 fn remove_by_event_id(
89 &self, 89 &self,
@@ -91,6 +91,26 @@ impl DeletionPolicy {
91 target_id_hex: &str, 91 target_id_hex: &str,
92 _deletion_created_at: u64, 92 _deletion_created_at: u64,
93 ) { 93 ) {
94 // --- Check PR events (kind 1617/1618) first — O(1) direct lookup ---
95 // PR purgatory is keyed by event ID hex, so this is the cheapest check.
96 // Only remove if the entry has an actual event (not a placeholder) and the
97 // event's author matches the deletion request author.
98 if let Some(entry) = self.ctx.purgatory.find_pr(target_id_hex) {
99 if let Some(ref event) = entry.event {
100 if event.pubkey == *author {
101 tracing::info!(
102 event_id = %target_id_hex,
103 author = %author.to_hex(),
104 "Deletion request: removing purgatory PR event by event ID"
105 );
106 self.ctx.purgatory.remove_pr(target_id_hex);
107 return;
108 }
109 }
110 // Entry exists but is a placeholder or wrong author — don't remove
111 return;
112 }
113
94 // --- Check announcements (kind 30617) --- 114 // --- Check announcements (kind 30617) ---
95 // The DashMap doesn't expose a direct "find by event ID" method, so we use 115 // The DashMap doesn't expose a direct "find by event ID" method, so we use
96 // the announcements_for_sync snapshot to enumerate all (repo_id, _) pairs. 116 // the announcements_for_sync snapshot to enumerate all (repo_id, _) pairs.