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,
50 /// Set the URL for opentelemetry exports. If you do not have an opentelemetry collector, do not set this option
53 pub opentelemetry_url: Option<String>,
56 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
58 pub struct PictrsConfig {
59 /// Address where pictrs is available (for image hosting)
60 #[default("http://pictrs:8080")]
63 /// Set a custom pictrs API key. ( Required for deleting images )
68 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
70 pub struct CaptchaConfig {
71 /// Whether captcha is required for signup
74 /// Can be easy, medium, or hard
76 pub difficulty: String,
79 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
81 pub struct DatabaseConfig {
82 /// Username to connect to postgres
84 pub(super) user: String,
85 /// Password to connect to postgres
86 #[default("password")]
88 #[default("localhost")]
89 /// Host where postgres is running
91 /// Port where postgres can be accessed
94 /// Name of the postgres database for lemmy
96 pub(super) database: String,
97 /// Maximum number of active sql connections
102 #[derive(Debug, Deserialize, Serialize, Clone, Document, SmartDefault)]
103 pub struct EmailConfig {
104 /// Hostname and port of the smtp server
105 #[doku(example = "localhost:25")]
106 pub smtp_server: String,
107 /// Login name for smtp server
108 pub smtp_login: Option<String>,
109 /// Password to login to the smtp server
110 pub smtp_password: Option<String>,
111 #[doku(example = "noreply@example.com")]
112 /// Address to send emails from, eg "noreply@your-instance.com"
113 pub smtp_from_address: String,
114 /// Whether or not smtp connections should use tls. Can be none, tls, or starttls
116 #[doku(example = "none")]
117 pub tls_type: String,
120 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
122 pub struct FederationConfig {
123 /// Whether to enable activitypub federation.
126 /// Allows and blocks are described here:
127 /// https://join-lemmy.org/docs/en/administration/federation_getting_started.html
129 /// list of instances with which federation is allowed
131 #[doku(example = "instance1.tld")]
132 #[doku(example = "instance2.tld")]
133 pub allowed_instances: Option<Vec<String>>,
134 /// Instances which we never federate anything with (but previously federated objects are unaffected)
136 pub blocked_instances: Option<Vec<String>>,
137 /// If true, only federate with instances on the allowlist and block everything else. If false,
138 /// use allowlist only for remote communities, and posts/comments in local communities
139 /// (meaning remote communities will show content from arbitrary instances).
141 pub strict_allowlist: bool,
142 /// Maximum number of HTTP requests allowed to handle a single incoming activity (or a single object fetch through the search).
144 pub http_fetch_retry_limit: i32,
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>,