diff options
Diffstat (limited to 'src/nostr/policy/deletion.rs')
| -rw-r--r-- | src/nostr/policy/deletion.rs | 24 |
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. |