use crate::config; /// Relay Info use serde::{Deserialize, Serialize}; const CARGO_PKG_VERSION: Option<&'static str> = option_env!("CARGO_PKG_VERSION"); #[derive(Debug, Serialize, Deserialize)] #[allow(unused)] pub struct RelayInfo { #[serde(skip_serializing_if = "Option::is_none")] pub id: Option, #[serde(skip_serializing_if = "Option::is_none")] pub name: Option, #[serde(skip_serializing_if = "Option::is_none")] pub description: Option, #[serde(skip_serializing_if = "Option::is_none")] pub pubkey: Option, #[serde(skip_serializing_if = "Option::is_none")] pub contact: Option, #[serde(skip_serializing_if = "Option::is_none")] pub supported_nips: Option>, #[serde(skip_serializing_if = "Option::is_none")] pub software: Option, #[serde(skip_serializing_if = "Option::is_none")] pub version: Option, } /// Convert an Info configuration into public Relay Info impl From for RelayInfo { fn from(i: config::Info) -> Self { RelayInfo { id: i.relay_url, name: i.name, description: i.description, pubkey: i.pubkey, contact: i.contact, supported_nips: Some(vec![1, 2, 11]), software: Some("https://git.sr.ht/~gheartsfield/nostr-rs-relay".to_owned()), version: CARGO_PKG_VERSION.map(|x| x.to_owned()), } } }