mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2025-03-28 05:12:27 -04:00
This is inspired by the work of v0l (https://github.com/v0l/nostr-rs-relay/). A new trait abstracts the storage layer with an async API. Rusqlite is still used with worker threads, but this allows for Postgresql or other backends to be used. There may be bugs, this has not been rigorously tested.
44 lines
1.5 KiB
Rust
44 lines
1.5 KiB
Rust
//! Relay metadata using NIP-11
|
|
/// Relay Info
|
|
use crate::config;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
pub 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<String>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub name: Option<String>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub description: Option<String>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub pubkey: Option<String>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub contact: Option<String>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub supported_nips: Option<Vec<i64>>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub software: Option<String>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub version: Option<String>,
|
|
}
|
|
|
|
/// Convert an Info configuration into public Relay Info
|
|
impl From<config::Info> 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, 9, 11, 12, 15, 16, 20, 22]),
|
|
software: Some("https://git.sr.ht/~gheartsfield/nostr-rs-relay".to_owned()),
|
|
version: CARGO_PKG_VERSION.map(std::borrow::ToOwned::to_owned),
|
|
}
|
|
}
|
|
}
|