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>,
44 #[doku(example = "(\\bThis\\b)|(\\bis\\b)|(\\bsample\\b)")]
45 pub slur_filter: Option<String>,
46 /// Maximum length of local community and user names
48 pub actor_name_max_length: usize,
49 /// Maximum number of HTTP requests allowed to handle a single incoming activity (or a single object fetch through the search).
51 pub http_fetch_retry_limit: i32,
54 #[doku(example = "http://localhost:4317")]
55 pub opentelemetry_url: Option<String>,
58 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
60 pub struct CaptchaConfig {
61 /// Whether captcha is required for signup
64 /// Can be easy, medium, or hard
66 pub difficulty: String,
69 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
71 pub struct DatabaseConfig {
72 /// Username to connect to postgres
74 pub(super) user: String,
75 /// Password to connect to postgres
76 #[default("password")]
78 #[default("localhost")]
79 /// Host where postgres is running
81 /// Port where postgres can be accessed
84 /// Name of the postgres database for lemmy
86 pub(super) database: String,
87 /// Maximum number of active sql connections
92 #[derive(Debug, Deserialize, Serialize, Clone, Document)]
93 pub struct EmailConfig {
94 /// Hostname and port of the smtp server
95 #[doku(example = "localhost:25")]
96 pub smtp_server: String,
97 /// Login name for smtp server
98 pub smtp_login: Option<String>,
99 /// Password to login to the smtp server
100 pub smtp_password: Option<String>,
101 #[doku(example = "noreply@example.com")]
102 /// Address to send emails from, eg "noreply@your-instance.com"
103 pub smtp_from_address: String,
104 /// Whether or not smtp connections should use tls
108 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
110 pub struct FederationConfig {
111 /// Whether to enable activitypub federation.
114 /// Allows and blocks are described here:
115 /// https://join-lemmy.org/docs/en/federation/administration.html///instance-allowlist-and-blocklist
117 /// list of instances with which federation is allowed
119 #[doku(example = "instance1.tld")]
120 #[doku(example = "instance2.tld")]
121 pub allowed_instances: Option<Vec<String>>,
122 /// Instances which we never federate anything with (but previously federated objects are unaffected)
124 pub blocked_instances: Option<Vec<String>>,
125 /// If true, only federate with instances on the allowlist and block everything else. If false,
126 /// use allowlist only for remote communities, and posts/comments in local communities
127 /// (meaning remote communities will show content from arbitrary instances).
129 pub strict_allowlist: bool,
132 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
134 pub struct RateLimitConfig {
135 /// Maximum number of messages created in interval
138 /// Interval length for message limit, in seconds
140 pub message_per_second: i32,
141 /// Maximum number of posts created in interval
144 /// Interval length for post limit, in seconds
146 pub post_per_second: i32,
147 /// Maximum number of registrations in interval
150 /// Interval length for registration limit, in seconds
152 pub register_per_second: i32,
153 /// Maximum number of image uploads in interval
156 /// Interval length for image uploads, in seconds
158 pub image_per_second: i32,
159 /// Maximum number of comments created in interval
162 /// Interval length for comment limit, in seconds
164 pub comment_per_second: i32,
167 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
168 pub struct SetupConfig {
169 /// Username for the admin user
170 #[doku(example = "admin")]
171 pub admin_username: String,
172 /// Password for the admin user. It must be at least 10 characters.
173 #[doku(example = "my_passwd_longer_than_ten_characters")]
174 pub admin_password: String,
175 /// Name of the site (can be changed later)
176 #[doku(example = "My Lemmy Instance")]
177 pub site_name: String,
178 /// Email for the admin user (optional, can be omitted and set later through the website)
180 pub admin_email: Option<String>,
182 pub sidebar: Option<String>,
184 pub description: Option<String>,
186 pub icon: Option<String>,
188 pub banner: Option<String>,
190 pub enable_downvotes: Option<bool>,
192 pub open_registration: Option<bool>,
194 pub enable_nsfw: Option<bool>,
196 pub community_creation_admin_only: Option<bool>,
198 pub require_email_verification: Option<bool>,
200 pub require_application: Option<bool>,
202 pub application_question: Option<String>,
204 pub private_instance: Option<bool>,