2 use serde::{Deserialize, Serialize};
3 use std::net::{IpAddr, Ipv4Addr};
5 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
8 /// settings related to the postgresql database
10 pub database: DatabaseConfig,
11 #[default(Some(RateLimitConfig::default()))]
12 /// rate limits for various user actions, by user ip
13 pub rate_limit: Option<RateLimitConfig>,
14 /// Settings related to activitypub federation
15 #[default(FederationConfig::default())]
16 pub federation: FederationConfig,
17 #[default(CaptchaConfig::default())]
18 pub captcha: CaptchaConfig,
19 /// Email sending configuration. All options except login/password are mandatory
21 pub email: Option<EmailConfig>,
22 /// Parameters for automatic configuration of new instance (only used at first start)
24 pub setup: Option<SetupConfig>,
25 /// the domain name of your instance (mandatory)
27 #[doku(example = "example.com")]
29 /// Address where lemmy should listen for incoming requests
30 #[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))]
31 #[doku(as = "String")]
33 /// Port where lemmy should listen for incoming requests
36 /// Whether the site is available over TLS. Needs to be true for federation to work.
38 pub tls_enabled: bool,
39 /// Address where pictrs is available (for image hosting)
41 #[doku(example = "http://localhost:8080")]
42 pub pictrs_url: Option<String>,
43 /// Regex for slurs which are prohibited. Example: `(\bThis\b)|(\bis\b)|(\bsample\b)`
45 pub additional_slurs: Option<String>,
46 /// Maximum length of local community and user names
48 pub actor_name_max_length: usize,
51 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
53 pub struct CaptchaConfig {
54 /// Whether captcha is required for signup
57 /// Can be easy, medium, or hard
59 pub difficulty: String,
62 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
64 pub struct DatabaseConfig {
65 /// Username to connect to postgres
67 pub(super) user: String,
68 /// Password to connect to postgres
69 #[default("password")]
71 #[default("localhost")]
72 /// Host where postgres is running
74 /// Port where postgres can be accessed
77 /// Name of the postgres database for lemmy
79 pub(super) database: String,
80 /// Maximum number of active sql connections
85 #[derive(Debug, Deserialize, Serialize, Clone, Document)]
86 pub struct EmailConfig {
87 /// Hostname and port of the smtp server
88 #[doku(example = "localhost:25")]
89 pub smtp_server: String,
90 /// Login name for smtp server
91 pub smtp_login: Option<String>,
92 /// Password to login to the smtp server
93 pub smtp_password: Option<String>,
94 #[doku(example = "noreply@example.com")]
95 /// Address to send emails from, eg "noreply@your-instance.com"
96 pub smtp_from_address: String,
97 /// Whether or not smtp connections should use tls
101 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
103 pub struct FederationConfig {
104 /// Whether to enable activitypub federation.
107 /// Allows and blocks are described here:
108 /// https://join-lemmy.org/docs/en/federation/administration.html///instance-allowlist-and-blocklist
110 /// list of instances with which federation is allowed
112 #[doku(example = "instance1.tld")]
113 #[doku(example = "instance2.tld")]
114 pub allowed_instances: Option<Vec<String>>,
115 /// Instances which we never federate anything with (but previously federated objects are unaffected)
117 pub blocked_instances: Option<Vec<String>>,
118 /// If true, only federate with instances on the allowlist and block everything else. If false,
119 /// use allowlist only for remote communities, and posts/comments in local communities
120 /// (meaning remote communities will show content from arbitrary instances).
122 pub strict_allowlist: bool,
125 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
127 pub struct RateLimitConfig {
128 /// Maximum number of messages created in interval
131 /// Interval length for message limit, in seconds
133 pub message_per_second: i32,
134 /// Maximum number of posts created in interval
137 /// Interval length for post limit, in seconds
139 pub post_per_second: i32,
140 /// Maximum number of registrations in interval
143 /// Interval length for registration limit, in seconds
145 pub register_per_second: i32,
146 /// Maximum number of image uploads in interval
149 /// Interval length for image uploads, in seconds
151 pub image_per_second: i32,
154 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
155 pub struct SetupConfig {
156 /// Username for the admin user
157 #[doku(example = "admin")]
158 pub admin_username: String,
159 /// Password for the admin user
160 #[doku(example = "my_passwd")]
161 pub admin_password: String,
162 /// Name of the site (can be changed later)
163 #[doku(example = "My Lemmy Instance")]
164 pub site_name: String,
165 /// Email for the admin user (optional, can be omitted and set later through the website)
167 pub admin_email: Option<String>,
169 pub sidebar: Option<String>,
171 pub description: Option<String>,
173 pub icon: Option<String>,
175 pub banner: Option<String>,
177 pub enable_downvotes: Option<bool>,
179 pub open_registration: Option<bool>,
181 pub enable_nsfw: Option<bool>,
183 pub community_creation_admin_only: Option<bool>,