Support NIP-40 Expiration timestamp

This commit is contained in:
Mike Dilger 2024-04-10 08:19:46 +12:00
parent d8b17b0402
commit dbca0ddb4e
2 changed files with 9 additions and 3 deletions

View File

@ -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;

View File

@ -35,20 +35,20 @@ pub async fn serve_nip11(peer: HashedPeer) -> Result<Response<Body>, 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