From 0c01797812bb77fc81d0efe58f0e7858f2b7af66 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 18 Feb 2026 09:24:01 +0000 Subject: 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. --- src/nostr/policy/related.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/nostr/policy/related.rs') 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 { .push((addr, pubkey, identifier)); } + // NOTE: Intentionally only checks the database (promoted announcements), not purgatory. + // Related events should only be accepted once the repository announcement has been + // validated (promoted via git data). Events referencing purgatory-only repositories + // are correctly rejected as orphans and can be re-submitted after promotion. + // Query each kind group for (kind, refs) in by_kind { let authors: Vec = refs.iter().map(|(_, pk, _)| *pk).collect(); -- cgit v1.2.3