2 use serde::Deserialize;
5 #[derive(Debug, Deserialize, Clone, Merge)]
7 pub(crate) database: Option<DatabaseConfig>,
8 pub(crate) rate_limit: Option<RateLimitConfig>,
9 pub(crate) federation: Option<FederationConfig>,
10 pub(crate) hostname: Option<String>,
11 pub(crate) bind: Option<IpAddr>,
12 pub(crate) port: Option<u16>,
13 pub(crate) tls_enabled: Option<bool>,
14 pub(crate) jwt_secret: Option<String>,
15 pub(crate) pictrs_url: Option<String>,
16 pub(crate) iframely_url: Option<String>,
17 pub(crate) captcha: Option<CaptchaConfig>,
18 pub(crate) email: Option<EmailConfig>,
19 pub(crate) setup: Option<SetupConfig>,
20 pub(crate) additional_slurs: Option<String>,
21 pub(crate) actor_name_max_length: Option<usize>,
24 #[derive(Debug, Deserialize, Clone)]
25 pub struct CaptchaConfig {
27 pub difficulty: String,
30 #[derive(Debug, Deserialize, Clone)]
31 pub struct DatabaseConfig {
32 pub(super) user: Option<String>,
35 pub(super) port: Option<i32>,
36 pub(super) database: Option<String>,
37 pub(super) pool_size: Option<u32>,
41 pub fn user(&self) -> String {
45 .unwrap_or_else(|| DatabaseConfig::default().user.expect("missing user"))
47 pub fn port(&self) -> i32 {
50 .unwrap_or_else(|| DatabaseConfig::default().port.expect("missing port"))
52 pub fn database(&self) -> String {
53 self.database.to_owned().unwrap_or_else(|| {
54 DatabaseConfig::default()
56 .expect("missing database")
59 pub fn pool_size(&self) -> u32 {
60 self.pool_size.unwrap_or_else(|| {
61 DatabaseConfig::default()
63 .expect("missing pool_size")
68 #[derive(Debug, Deserialize, Clone)]
69 pub struct EmailConfig {
70 pub smtp_server: String,
71 pub smtp_login: Option<String>,
72 pub smtp_password: Option<String>,
73 pub smtp_from_address: String,
77 #[derive(Debug, Deserialize, Clone)]
78 pub struct FederationConfig {
80 pub allowed_instances: Option<Vec<String>>,
81 pub blocked_instances: Option<Vec<String>>,
82 pub strict_allowlist: Option<bool>,
85 #[derive(Debug, Deserialize, Clone)]
86 pub struct RateLimitConfig {
88 pub message_per_second: i32,
90 pub post_per_second: i32,
92 pub register_per_second: i32,
94 pub image_per_second: i32,
97 #[derive(Debug, Deserialize, Clone)]
98 pub struct SetupConfig {
99 pub admin_username: String,
100 pub admin_password: String,
101 pub admin_email: Option<String>,
102 pub site_name: String,