1 use serde::Deserialize;
2 use std::net::{IpAddr, Ipv4Addr};
4 #[derive(Debug, Deserialize, Clone, SmartDefault)]
8 pub database: DatabaseConfig,
9 #[default(Some(RateLimitConfig::default()))]
10 pub rate_limit: Option<RateLimitConfig>,
11 #[default(FederationConfig::default())]
12 pub federation: FederationConfig,
13 #[default(CaptchaConfig::default())]
14 pub captcha: CaptchaConfig,
16 pub email: Option<EmailConfig>,
18 pub setup: Option<SetupConfig>,
21 #[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))]
26 pub tls_enabled: bool,
28 pub pictrs_url: Option<String>,
30 pub additional_slurs: Option<String>,
32 pub actor_name_max_length: usize,
35 #[derive(Debug, Deserialize, Clone, SmartDefault)]
37 pub struct CaptchaConfig {
41 pub difficulty: String,
44 #[derive(Debug, Deserialize, Clone, SmartDefault)]
46 pub struct DatabaseConfig {
48 pub(super) user: String,
49 #[default("password")]
51 #[default("localhost")]
56 pub(super) database: String,
61 #[derive(Debug, Deserialize, Clone)]
62 pub struct EmailConfig {
63 pub smtp_server: String,
64 pub smtp_login: Option<String>,
65 pub smtp_password: Option<String>,
66 pub smtp_from_address: String,
70 #[derive(Debug, Deserialize, Clone, SmartDefault)]
72 pub struct FederationConfig {
76 pub allowed_instances: Option<Vec<String>>,
78 pub blocked_instances: Option<Vec<String>>,
80 pub strict_allowlist: bool,
83 #[derive(Debug, Deserialize, Clone, SmartDefault)]
85 pub struct RateLimitConfig {
89 pub message_per_second: i32,
93 pub post_per_second: i32,
97 pub register_per_second: i32,
101 pub image_per_second: i32,
104 #[derive(Debug, Deserialize, Clone, SmartDefault)]
105 pub struct SetupConfig {
106 pub admin_username: String,
107 pub admin_password: String,
108 pub site_name: String,
110 pub admin_email: Option<String>,
112 pub sidebar: Option<String>,
114 pub description: Option<String>,
116 pub icon: Option<String>,
118 pub banner: Option<String>,
120 pub enable_downvotes: Option<bool>,
122 pub open_registration: Option<bool>,
124 pub enable_nsfw: Option<bool>,
126 pub community_creation_admin_only: Option<bool>,