upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/nostr/builder.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-02-23 13:29:47 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-02-23 13:29:47 +0000
commit65ac6ef83205c41653e6ffe2acd664f968926fb2 (patch)
treec31301c599dfaffd75e61af3f6004d1b95373a72 /src/nostr/builder.rs
parentc368f9132a16d45a17ad55943e4b68ba85a6835b (diff)
feat: remove purgatory announcements on NIP-09 deletion events
Kind 5 deletion events signed by the announcement author now evict the corresponding purgatory entry and delete the bare repository from disk. Both NIP-09 reference styles are supported: - e tag (event ID): matches the purgatory entry whose event ID equals the tag value - a tag (coordinate 30617:<pubkey>:<identifier>): matches by coordinate, only removes entries with created_at <= deletion event created_at per NIP-09 spec Author-only enforcement: coordinate pubkey and e-tag owner must match the deletion event pubkey; third-party deletion attempts are silently ignored. Includes 6 unit tests and 2 integration tests (event ID and coordinate paths).
Diffstat (limited to 'src/nostr/builder.rs')
-rw-r--r--src/nostr/builder.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/nostr/builder.rs b/src/nostr/builder.rs
index c2d4939..d056e46 100644
--- a/src/nostr/builder.rs
+++ b/src/nostr/builder.rs
@@ -14,8 +14,8 @@ use nostr_relay_builder::prelude::*;
14use crate::config::{Config, DatabaseBackend}; 14use crate::config::{Config, DatabaseBackend};
15use crate::nostr::events::RepositoryAnnouncement; 15use crate::nostr::events::RepositoryAnnouncement;
16use crate::nostr::policy::{ 16use crate::nostr::policy::{
17 AnnouncementPolicy, AnnouncementResult, PolicyContext, PrEventPolicy, ReferenceResult, 17 AnnouncementPolicy, AnnouncementResult, DeletionPolicy, PolicyContext, PrEventPolicy,
18 RelatedEventPolicy, StatePolicy, StateResult, 18 ReferenceResult, RelatedEventPolicy, StatePolicy, StateResult,
19}; 19};
20 20
21 21
@@ -29,6 +29,7 @@ pub type SharedDatabase = Arc<dyn NostrDatabase>;
29/// - `StatePolicy` - State event validation + ref alignment 29/// - `StatePolicy` - State event validation + ref alignment
30/// - `PrEventPolicy` - PR/PR Update validation 30/// - `PrEventPolicy` - PR/PR Update validation
31/// - `RelatedEventPolicy` - Forward/backward reference checking 31/// - `RelatedEventPolicy` - Forward/backward reference checking
32/// - `DeletionPolicy` - NIP-09 event deletion request handling
32/// 33///
33/// Uses stateful database queries to check event relationships. 34/// Uses stateful database queries to check event relationships.
34#[derive(Clone)] 35#[derive(Clone)]
@@ -38,6 +39,7 @@ pub struct Nip34WritePolicy {
38 state_policy: StatePolicy, 39 state_policy: StatePolicy,
39 pr_event_policy: PrEventPolicy, 40 pr_event_policy: PrEventPolicy,
40 related_event_policy: RelatedEventPolicy, 41 related_event_policy: RelatedEventPolicy,
42 deletion_policy: DeletionPolicy,
41} 43}
42 44
43impl std::fmt::Debug for Nip34WritePolicy { 45impl std::fmt::Debug for Nip34WritePolicy {
@@ -69,6 +71,7 @@ impl Nip34WritePolicy {
69 state_policy: StatePolicy::new(ctx.clone()), 71 state_policy: StatePolicy::new(ctx.clone()),
70 pr_event_policy: PrEventPolicy::new(ctx.clone()), 72 pr_event_policy: PrEventPolicy::new(ctx.clone()),
71 related_event_policy: RelatedEventPolicy::new(ctx.clone()), 73 related_event_policy: RelatedEventPolicy::new(ctx.clone()),
74 deletion_policy: DeletionPolicy::new(ctx.clone()),
72 ctx, 75 ctx,
73 } 76 }
74 } 77 }
@@ -521,6 +524,7 @@ impl WritePolicy for Nip34WritePolicy {
521 ); 524 );
522 WritePolicyResult::Accept 525 WritePolicyResult::Accept
523 } 526 }
527 Kind::EventDeletion => self.deletion_policy.handle(event).await,
524 _ => self.handle_related_event(event, "Event").await, 528 _ => self.handle_related_event(event, "Event").await,
525 } 529 }
526 }) 530 })