2 use serde::{Deserialize, Serialize};
3 use std::net::{IpAddr, Ipv4Addr};
6 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
9 /// settings related to the postgresql database
10 #[default(Default::default())]
11 pub database: DatabaseConfig,
12 /// rate limits for various user actions, by user ip
13 #[default(Some(Default::default()))]
14 pub rate_limit: Option<RateLimitConfig>,
15 /// Settings related to activitypub federation
16 #[default(Default::default())]
17 pub federation: FederationConfig,
18 /// Pictrs image server configuration.
19 #[default(Some(Default::default()))]
20 pub(crate) pictrs: Option<PictrsConfig>,
21 #[default(Default::default())]
22 pub captcha: CaptchaConfig,
23 /// Email sending configuration. All options except login/password are mandatory
25 #[doku(example = "Some(Default::default())")]
26 pub email: Option<EmailConfig>,
27 /// Parameters for automatic configuration of new instance (only used at first start)
29 #[doku(example = "Some(Default::default())")]
30 pub setup: Option<SetupConfig>,
31 /// the domain name of your instance (mandatory)
33 #[doku(example = "example.com")]
35 /// Address where lemmy should listen for incoming requests
36 #[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))]
37 #[doku(as = "String")]
39 /// Port where lemmy should listen for incoming requests
42 /// Whether the site is available over TLS. Needs to be true for federation to work.
44 pub tls_enabled: bool,
46 #[doku(example = "(\\bThis\\b)|(\\bis\\b)|(\\bsample\\b)")]
47 /// A regex list of slurs to block / hide
48 pub slur_filter: Option<String>,
49 /// Maximum length of local community and user names
51 pub actor_name_max_length: usize,
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<Url>,
59 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
61 pub struct PictrsConfig {
62 /// Address where pictrs is available (for image hosting)
63 #[default(Url::parse("http://pictrs:8080").expect("parse pictrs url"))]
64 #[doku(example = "http://pictrs:8080")]
67 /// Set a custom pictrs API key. ( Required for deleting images )
69 pub api_key: Option<String>,
72 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
74 pub struct CaptchaConfig {
75 /// Whether captcha is required for signup
78 /// Can be easy, medium, or hard
80 pub difficulty: String,
83 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
85 pub struct DatabaseConfig {
86 /// Username to connect to postgres
88 pub(super) user: String,
89 /// Password to connect to postgres
90 #[default("password")]
92 #[default("localhost")]
93 /// Host where postgres is running
95 /// Port where postgres can be accessed
98 /// Name of the postgres database for lemmy
100 pub(super) database: String,
101 /// Maximum number of active sql connections
106 #[derive(Debug, Deserialize, Serialize, Clone, Document, SmartDefault)]
107 pub struct EmailConfig {
108 /// Hostname and port of the smtp server
109 #[doku(example = "localhost:25")]
110 pub smtp_server: String,
111 /// Login name for smtp server
112 pub smtp_login: Option<String>,
113 /// Password to login to the smtp server
114 pub smtp_password: Option<String>,
115 #[doku(example = "noreply@example.com")]
116 /// Address to send emails from, eg "noreply@your-instance.com"
117 pub smtp_from_address: String,
118 /// Whether or not smtp connections should use tls. Can be none, tls, or starttls
120 #[doku(example = "none")]
121 pub tls_type: String,
124 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
126 pub struct FederationConfig {
127 /// Whether to enable activitypub federation.
130 /// Allows and blocks are described here:
131 /// https://join-lemmy.org/docs/en/administration/federation_getting_started.html
133 /// list of instances with which federation is allowed
135 #[doku(example = "instance1.tld")]
136 #[doku(example = "instance2.tld")]
137 pub allowed_instances: Option<Vec<String>>,
138 /// Instances which we never federate anything with (but previously federated objects are unaffected)
140 pub blocked_instances: Option<Vec<String>>,
141 /// If true, only federate with instances on the allowlist and block everything else. If false,
142 /// use allowlist only for remote communities, and posts/comments in local communities
143 /// (meaning remote communities will show content from arbitrary instances).
145 pub strict_allowlist: bool,
146 /// Maximum number of HTTP requests allowed to handle a single incoming activity (or a single object fetch through the search).
148 pub http_fetch_retry_limit: i32,
149 /// Number of workers for sending outgoing activities. Search logs for "Activity queue stats" to
150 /// see information. If "running" number is consistently close to the worker_count, you should
153 pub worker_count: u64,
154 /// Use federation debug mode. Allows connecting to http and localhost urls. Also sends outgoing
155 /// activities synchronously for easier testing. Do not use in production.
160 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
162 pub struct RateLimitConfig {
163 /// Maximum number of messages created in interval
166 /// Interval length for message limit, in seconds
168 pub message_per_second: i32,
169 /// Maximum number of posts created in interval
172 /// Interval length for post limit, in seconds
174 pub post_per_second: i32,
175 /// Maximum number of registrations in interval
178 /// Interval length for registration limit, in seconds
180 pub register_per_second: i32,
181 /// Maximum number of image uploads in interval
184 /// Interval length for image uploads, in seconds
186 pub image_per_second: i32,
187 /// Maximum number of comments created in interval
190 /// Interval length for comment limit, in seconds
192 pub comment_per_second: i32,
195 /// Interval length for search limit, in seconds
197 pub search_per_second: i32,
200 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
201 pub struct SetupConfig {
202 /// Username for the admin user
203 #[doku(example = "admin")]
204 pub admin_username: String,
205 /// Password for the admin user. It must be at least 10 characters.
206 #[doku(example = "tf6HHDS4RolWfFhk4Rq9")]
207 pub admin_password: String,
208 /// Name of the site (can be changed later)
209 #[doku(example = "My Lemmy Instance")]
210 pub site_name: String,
211 /// Email for the admin user (optional, can be omitted and set later through the website)
212 #[doku(example = "user@example.com")]
214 pub admin_email: Option<String>,