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,
53 /// Set the URL for opentelemetry exports. If you do not have an opentelemetry collector, do not set this option
56 pub opentelemetry_url: Option<String>,
59 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
61 pub struct CaptchaConfig {
62 /// Whether captcha is required for signup
65 /// Can be easy, medium, or hard
67 pub difficulty: String,
70 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
72 pub struct DatabaseConfig {
73 /// Username to connect to postgres
75 pub(super) user: String,
76 /// Password to connect to postgres
77 #[default("password")]
79 #[default("localhost")]
80 /// Host where postgres is running
82 /// Port where postgres can be accessed
85 /// Name of the postgres database for lemmy
87 pub(super) database: String,
88 /// Maximum number of active sql connections
93 #[derive(Debug, Deserialize, Serialize, Clone, Document, SmartDefault)]
94 pub struct EmailConfig {
95 /// Hostname and port of the smtp server
96 #[doku(example = "localhost:25")]
97 pub smtp_server: String,
98 /// Login name for smtp server
99 pub smtp_login: Option<String>,
100 /// Password to login to the smtp server
101 pub smtp_password: Option<String>,
102 #[doku(example = "noreply@example.com")]
103 /// Address to send emails from, eg "noreply@your-instance.com"
104 pub smtp_from_address: String,
105 /// Whether or not smtp connections should use tls. Can be none, tls, or starttls
107 #[doku(example = "none")]
108 pub tls_type: String,
111 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
113 pub struct FederationConfig {
114 /// Whether to enable activitypub federation.
117 /// Allows and blocks are described here:
118 /// https://join-lemmy.org/docs/en/administration/federation_getting_started.html
120 /// list of instances with which federation is allowed
122 #[doku(example = "instance1.tld")]
123 #[doku(example = "instance2.tld")]
124 pub allowed_instances: Option<Vec<String>>,
125 /// Instances which we never federate anything with (but previously federated objects are unaffected)
127 pub blocked_instances: Option<Vec<String>>,
128 /// If true, only federate with instances on the allowlist and block everything else. If false,
129 /// use allowlist only for remote communities, and posts/comments in local communities
130 /// (meaning remote communities will show content from arbitrary instances).
132 pub strict_allowlist: bool,
133 /// Number of workers for sending outgoing activities. Search logs for "Activity queue stats" to
134 /// see information. If "running" number is consistently close to the worker_count, you should
137 pub worker_count: u64,
140 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
142 pub struct RateLimitConfig {
143 /// Maximum number of messages created in interval
146 /// Interval length for message limit, in seconds
148 pub message_per_second: i32,
149 /// Maximum number of posts created in interval
152 /// Interval length for post limit, in seconds
154 pub post_per_second: i32,
155 /// Maximum number of registrations in interval
158 /// Interval length for registration limit, in seconds
160 pub register_per_second: i32,
161 /// Maximum number of image uploads in interval
164 /// Interval length for image uploads, in seconds
166 pub image_per_second: i32,
167 /// Maximum number of comments created in interval
170 /// Interval length for comment limit, in seconds
172 pub comment_per_second: i32,
175 /// Interval length for search limit, in seconds
177 pub search_per_second: i32,
180 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
181 pub struct SetupConfig {
182 /// Username for the admin user
183 #[doku(example = "admin")]
184 pub admin_username: String,
185 /// Password for the admin user. It must be at least 10 characters.
186 #[doku(example = "my_passwd_longer_than_ten_characters")]
187 pub admin_password: String,
188 /// Name of the site (can be changed later)
189 #[doku(example = "My Lemmy Instance")]
190 pub site_name: String,
191 /// Email for the admin user (optional, can be omitted and set later through the website)
193 pub admin_email: Option<String>,
195 pub sidebar: Option<String>,
197 pub description: Option<String>,
199 pub icon: Option<String>,
201 pub banner: Option<String>,
203 pub enable_downvotes: Option<bool>,
205 pub open_registration: Option<bool>,
207 pub enable_nsfw: Option<bool>,
209 pub community_creation_admin_only: Option<bool>,
211 pub require_email_verification: Option<bool>,
213 pub require_application: Option<bool>,
215 pub application_question: Option<String>,
217 pub private_instance: Option<bool>,
219 pub default_theme: Option<String>,