upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/nostr/policy/related.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-02-18 09:24:01 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-02-18 09:24:01 +0000
commit0c01797812bb77fc81d0efe58f0e7858f2b7af66 (patch)
tree9310aca4f3e921ca9950a2b11af23ea82788b98b /src/nostr/policy/related.rs
parent467690f33bbbfd442852e61de221e4e5e161b878 (diff)
fix: handle announcement replacement when original is still in purgatory
Previously, has_active_announcement() only queried the database, so when a newer announcement arrived for the same (pubkey, identifier) while the original was still in purgatory, it was incorrectly routed as a brand-new announcement (AcceptPurgatory) rather than replacing the existing entry. This change splits the logic into two cases: - If the existing entry is in the database: return Accept (replacement) as before - If the existing entry is only in purgatory: replace the purgatory entry via add_announcement() (which overwrites by key) and extend expiries for both the announcement and any waiting state events, then return Accept - If the owner sends a Reject-classified announcement (service removed) but has a purgatory entry: clear the purgatory entry, delete the bare repo, and remove any waiting state events before rejecting Also add an explicit comment to find_accepted_repository() in related.rs clarifying that it intentionally only checks the database. Related events should only be accepted after the repository announcement has been promoted (validated via git data) - this is correct behaviour, not a missing check.
Diffstat (limited to 'src/nostr/policy/related.rs')
-rw-r--r--src/nostr/policy/related.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/nostr/policy/related.rs b/src/nostr/policy/related.rs
index 7ce87db..cfe04a7 100644
--- a/src/nostr/policy/related.rs
+++ b/src/nostr/policy/related.rs
@@ -139,6 +139,11 @@ impl RelatedEventPolicy {
139 .push((addr, pubkey, identifier)); 139 .push((addr, pubkey, identifier));
140 } 140 }
141 141
142 // NOTE: Intentionally only checks the database (promoted announcements), not purgatory.
143 // Related events should only be accepted once the repository announcement has been
144 // validated (promoted via git data). Events referencing purgatory-only repositories
145 // are correctly rejected as orphans and can be re-submitted after promotion.
146
142 // Query each kind group 147 // Query each kind group
143 for (kind, refs) in by_kind { 148 for (kind, refs) in by_kind {
144 let authors: Vec<PublicKey> = refs.iter().map(|(_, pk, _)| *pk).collect(); 149 let authors: Vec<PublicKey> = refs.iter().map(|(_, pk, _)| *pk).collect();