feat(NIP-22): advertise support for event created_at limits

The `reject_future_limits` option can now be disabled, and is by
default.

NIP-11 advertises support for created_at limits.

The message for future-dated events has been modified, to be closer to
the recommended example in the NIP.
This commit is contained in:
Greg Heartsfield
2022-09-10 20:40:10 -05:00
parent 283967f8cc
commit 72f1c19b21
5 changed files with 8 additions and 6 deletions
+1 -1
View File
@@ -219,7 +219,7 @@ impl Default for Settings {
whitelist_addresses: None, // whitelisted addresses (never delete)
},
options: Options {
reject_future_seconds: Some(30 * 60), // Reject events 30min in the future or greater
reject_future_seconds: None, // Reject events in the future if defined
},
}
}
+1 -1
View File
@@ -35,7 +35,7 @@ impl From<config::Info> for RelayInfo {
description: i.description,
pubkey: i.pubkey,
contact: i.contact,
supported_nips: Some(vec![1, 2, 11, 15, 16]),
supported_nips: Some(vec![1, 2, 11, 15, 16, 22]),
software: Some("https://git.sr.ht/~gheartsfield/nostr-rs-relay".to_owned()),
version: CARGO_PKG_VERSION.map(|x| x.to_owned()),
}
+3 -2
View File
@@ -529,8 +529,9 @@ async fn nostr_server(
client_published_event_count += 1;
} else {
info!("client {:?} sent a far future-dated event", cid);
ws_stream.send(make_notice_message("event was too far in the future")).await.ok();
if let Some(fut_sec) = settings.options.reject_future_seconds {
ws_stream.send(make_notice_message(&format!("The event created_at field is out of the acceptable range (+{}sec) for this relay and was not stored.",fut_sec))).await.ok();
}
}
},
Err(_) => {