From dbca0ddb4e43ea53e43ef29c1caafd3948044d7a Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Wed, 10 Apr 2024 08:19:46 +1200 Subject: [PATCH] Support NIP-40 Expiration timestamp --- chorus-bin/src/nostr.rs | 6 ++++++ chorus-bin/src/web.rs | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/chorus-bin/src/nostr.rs b/chorus-bin/src/nostr.rs index e265bc2..059e00b 100644 --- a/chorus-bin/src/nostr.rs +++ b/chorus-bin/src/nostr.rs @@ -488,6 +488,12 @@ pub fn screen_outgoing_event( return event_flags.tags_current_user || event_flags.author_is_current_user; } + // Forbid (and delete) if it has an expired expiration tag + if matches!(event.is_expired(), Ok(true)) { + let _ = GLOBALS.store.get().unwrap().delete_event(event.id()); + return false; + } + // Allow if an open relay if GLOBALS.config.read().open_relay { return true; diff --git a/chorus-bin/src/web.rs b/chorus-bin/src/web.rs index ff2fe34..cacc9c4 100644 --- a/chorus-bin/src/web.rs +++ b/chorus-bin/src/web.rs @@ -35,20 +35,20 @@ pub async fn serve_nip11(peer: HashedPeer) -> Result, Error> { fn build_rid(config: &Config) -> String { let mut rid: String = String::with_capacity(255); - const SUPPORTED_NIPS: [u8; 7] = [ + const SUPPORTED_NIPS: [u8; 8] = [ 1, // nostr 4, // DMs 9, // Event Deletion 11, // relay information document + 40, // Expiration Timestamp 42, // AUTH 59, // GiftWrap 65, // Relay List Metadata ]; - const _UNSUPPORTED_NIPS: [u8; 8] = [ + const _UNSUPPORTED_NIPS: [u8; 7] = [ 26, // Delegated Event Signing 28, // Public Chat 29, // Relay-based Groups - 40, // Expiration Timestamp 45, // Counting results 50, // SEARCH 94, // File Metadata