From 7120de4ff805c8fb36c67600056cf15eafc333a9 Mon Sep 17 00:00:00 2001 From: Kieran Date: Mon, 20 Nov 2023 10:20:15 +0000 Subject: [PATCH] feat: restricted_writes Signed-off-by: Greg Heartsfield --- config.toml | 5 +++++ src/config.rs | 2 ++ src/info.rs | 9 +++++++++ 3 files changed, 16 insertions(+) diff --git a/config.toml b/config.toml index 109efd2..56973cf 100644 --- a/config.toml +++ b/config.toml @@ -75,6 +75,11 @@ description = "A newly created nostr-rs-relay.\n\nCustomize this with your own i # `proto/nauthz.proto`. # event_admission_server = "http://[::1]:50051" +# If the event admission server denies writes +# in any case (excluding spam filtering). +# This is reflected in the relay information document. +# restricts_write = true + [network] # Bind to this network address address = "0.0.0.0" diff --git a/src/config.rs b/src/config.rs index 52f0922..399b831 100644 --- a/src/config.rs +++ b/src/config.rs @@ -32,6 +32,7 @@ pub struct Database { #[allow(unused)] pub struct Grpc { pub event_admission_server: Option, + pub restricts_write: bool, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -287,6 +288,7 @@ impl Default for Settings { }, grpc: Grpc { event_admission_server: None, + restricts_write: false, }, network: Network { port: 8080, diff --git a/src/info.rs b/src/info.rs index f35f21c..b8ac975 100644 --- a/src/info.rs +++ b/src/info.rs @@ -13,6 +13,9 @@ pub const UNIT: &str = "msats"; pub struct Limitation { #[serde(skip_serializing_if = "Option::is_none")] payment_required: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + restricted_writes: Option, } #[derive(Serialize, Deserialize, Debug)] @@ -75,6 +78,12 @@ impl From for RelayInfo { let limitations = Limitation { payment_required: Some(p.enabled), + restricted_writes: Some( + p.enabled + || c.verified_users.is_enabled() + || c.authorization.pubkey_whitelist.is_some() + || c.grpc.restricts_write, + ), }; let (payment_url, fees) = if p.enabled {