Skip to content

Commit

Permalink
feat: restricted_writes
Browse files Browse the repository at this point in the history
Signed-off-by: Greg Heartsfield <[email protected]>
  • Loading branch information
v0l authored and scsibug committed Nov 23, 2023
1 parent 4ff77ab commit 7120de4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub struct Database {
#[allow(unused)]
pub struct Grpc {
pub event_admission_server: Option<String>,
pub restricts_write: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down Expand Up @@ -287,6 +288,7 @@ impl Default for Settings {
},
grpc: Grpc {
event_admission_server: None,
restricts_write: false,
},
network: Network {
port: 8080,
Expand Down
9 changes: 9 additions & 0 deletions src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ pub const UNIT: &str = "msats";
pub struct Limitation {
#[serde(skip_serializing_if = "Option::is_none")]
payment_required: Option<bool>,

#[serde(skip_serializing_if = "Option::is_none")]
restricted_writes: Option<bool>,
}

#[derive(Serialize, Deserialize, Debug)]
Expand Down Expand Up @@ -75,6 +78,12 @@ impl From<Settings> 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 {
Expand Down

0 comments on commit 7120de4

Please sign in to comment.