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 /// Pictrs image server configuration.
19 pub(crate) pictrs_config: Option<PictrsConfig>,
20 #[default(CaptchaConfig::default())]
21 pub captcha: CaptchaConfig,
22 /// Email sending configuration. All options except login/password are mandatory
24 pub email: Option<EmailConfig>,
25 /// Parameters for automatic configuration of new instance (only used at first start)
27 pub setup: Option<SetupConfig>,
28 /// the domain name of your instance (mandatory)
30 #[doku(example = "example.com")]
32 /// Address where lemmy should listen for incoming requests
33 #[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))]
34 #[doku(as = "String")]
36 /// Port where lemmy should listen for incoming requests
39 /// Whether the site is available over TLS. Needs to be true for federation to work.
41 pub tls_enabled: bool,
43 #[doku(example = "(\\bThis\\b)|(\\bis\\b)|(\\bsample\\b)")]
44 /// A regex list of slurs to block / hide
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 PictrsConfig {
62 /// Address where pictrs is available (for image hosting)
63 #[default("http://pictrs:8080")]
66 /// Set a custom pictrs API key. ( Required for deleting images )
71 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
73 pub struct CaptchaConfig {
74 /// Whether captcha is required for signup
77 /// Can be easy, medium, or hard
79 pub difficulty: String,
82 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
84 pub struct DatabaseConfig {
85 /// Username to connect to postgres
87 pub(super) user: String,
88 /// Password to connect to postgres
89 #[default("password")]
91 #[default("localhost")]
92 /// Host where postgres is running
94 /// Port where postgres can be accessed
97 /// Name of the postgres database for lemmy
99 pub(super) database: String,
100 /// Maximum number of active sql connections
105 #[derive(Debug, Deserialize, Serialize, Clone, Document, SmartDefault)]
106 pub struct EmailConfig {
107 /// Hostname and port of the smtp server
108 #[doku(example = "localhost:25")]
109 pub smtp_server: String,
110 /// Login name for smtp server
111 pub smtp_login: Option<String>,
112 /// Password to login to the smtp server
113 pub smtp_password: Option<String>,
114 #[doku(example = "noreply@example.com")]
115 /// Address to send emails from, eg "noreply@your-instance.com"
116 pub smtp_from_address: String,
117 /// Whether or not smtp connections should use tls. Can be none, tls, or starttls
119 #[doku(example = "none")]
120 pub tls_type: String,
123 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
125 pub struct FederationConfig {
126 /// Whether to enable activitypub federation.
129 /// Allows and blocks are described here:
130 /// https://join-lemmy.org/docs/en/administration/federation_getting_started.html
132 /// list of instances with which federation is allowed
134 #[doku(example = "instance1.tld")]
135 #[doku(example = "instance2.tld")]
136 pub allowed_instances: Option<Vec<String>>,
137 /// Instances which we never federate anything with (but previously federated objects are unaffected)
139 pub blocked_instances: Option<Vec<String>>,
140 /// If true, only federate with instances on the allowlist and block everything else. If false,
141 /// use allowlist only for remote communities, and posts/comments in local communities
142 /// (meaning remote communities will show content from arbitrary instances).
144 pub strict_allowlist: bool,
145 /// Number of workers for sending outgoing activities. Search logs for "Activity queue stats" to
146 /// see information. If "running" number is consistently close to the worker_count, you should
149 pub worker_count: u64,
150 /// Use federation debug mode. Allows connecting to http and localhost urls. Also sends outgoing
151 /// activities synchronously for easier testing. Do not use in production.
156 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
158 pub struct RateLimitConfig {
159 /// Maximum number of messages created in interval
162 /// Interval length for message limit, in seconds
164 pub message_per_second: i32,
165 /// Maximum number of posts created in interval
168 /// Interval length for post limit, in seconds
170 pub post_per_second: i32,
171 /// Maximum number of registrations in interval
174 /// Interval length for registration limit, in seconds
176 pub register_per_second: i32,
177 /// Maximum number of image uploads in interval
180 /// Interval length for image uploads, in seconds
182 pub image_per_second: i32,
183 /// Maximum number of comments created in interval
186 /// Interval length for comment limit, in seconds
188 pub comment_per_second: i32,
191 /// Interval length for search limit, in seconds
193 pub search_per_second: i32,
196 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
197 pub struct SetupConfig {
198 /// Username for the admin user
199 #[doku(example = "admin")]
200 pub admin_username: String,
201 /// Password for the admin user. It must be at least 10 characters.
202 #[doku(example = "tf6HHDS4RolWfFhk4Rq9")]
203 pub admin_password: String,
204 /// Name of the site (can be changed later)
205 #[doku(example = "My Lemmy Instance")]
206 pub site_name: String,
207 /// Email for the admin user (optional, can be omitted and set later through the website)
208 #[doku(example = "user@example.com")]
210 pub admin_email: Option<String>,