From 24691276a9d9f421c8f100e42bbbf0d691c0de8e Mon Sep 17 00:00:00 2001 From: naskya Date: Thu, 20 Jun 2024 07:31:09 +0900 Subject: [PATCH] WIP --- Cargo.lock | 1 - Cargo.toml | 1 - src/config/client.rs | 5 ----- src/config/server.rs | 36 +++++++++++++++++++++++++++++++----- 4 files changed, 31 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aa02784..79e3896 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -425,7 +425,6 @@ dependencies = [ "clap", "color-print", "serde", - "serde_json", "sqlx", "thiserror", "tokio", diff --git a/Cargo.toml b/Cargo.toml index f0f79fe..70b82c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,6 @@ clap = { version = "4.5", features = ["derive"] } color-print = "0.3" thiserror = "1.0" serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" sqlx = { version = "0.7", features = ["runtime-tokio", "postgres"] } tokio = { version = "1.38", features = ["full"] } toml = "0.8" diff --git a/src/config/client.rs b/src/config/client.rs index 8d9a088..223f04c 100644 --- a/src/config/client.rs +++ b/src/config/client.rs @@ -10,11 +10,6 @@ use validator::{Validate, ValidationError}; #[derive(Deserialize, Serialize, Validate, Debug)] pub struct Config { - appearance: Appearance, -} - -#[derive(Deserialize, Serialize, Validate, Debug)] -pub struct Appearance { /// Server-wide default light theme light_theme: Option, /// Server-wide default light theme diff --git a/src/config/server.rs b/src/config/server.rs index 6356a89..a9f603e 100644 --- a/src/config/server.rs +++ b/src/config/server.rs @@ -8,21 +8,47 @@ use serde::{Deserialize, Serialize}; use validator::Validate; -type Port = u16; - #[derive(Deserialize, Serialize, Validate, Debug)] pub struct Config { + info: Option, + timelines: Option, network: Network, database: Database, cache_server: CacheServer, id: Option, } +#[derive(Deserialize, Serialize, Validate, Debug)] +pub struct Info { + /// Server name + name: Option, + /// Server description + description: Option, + /// Name/handle of the server maintainer + maintainer_name: Option, + /// Contact info (e.g., email) of the server maintainer + contact_info: Option, + /// Whether the server allows open self-registration + open_registrations: bool, + /// Repository URL + repository_url: Option, +} + +#[derive(Deserialize, Serialize, Validate, Debug)] +pub struct Timelines { + /// Whether to enable the local timeline + local: bool, + /// Whether to enable the global timeline + global: bool, + /// Whether to publish the local/global timelines to signed out users + guest: bool, +} + #[derive(Deserialize, Serialize, Validate, Debug)] pub struct Network { protocol: Option, host: String, - port: Port, + port: u16, } #[derive(Deserialize, Serialize, Debug)] @@ -34,7 +60,7 @@ pub enum HttpProtocol { #[derive(Deserialize, Serialize, Validate, Debug)] pub struct Database { host: String, - port: Port, + port: u16, user: String, password: String, name: String, @@ -43,7 +69,7 @@ pub struct Database { #[derive(Deserialize, Serialize, Validate, Debug)] pub struct CacheServer { host: String, - port: Port, + port: u16, user: Option, password: Option, index: Option,