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 /// Settings related to activitypub federation
13 /// Pictrs image server configuration.
14 #[default(Some(Default::default()))]
15 pub(crate) pictrs: Option<PictrsConfig>,
16 /// Email sending configuration. All options except login/password are mandatory
18 #[doku(example = "Some(Default::default())")]
19 pub email: Option<EmailConfig>,
20 /// Parameters for automatic configuration of new instance (only used at first start)
22 #[doku(example = "Some(Default::default())")]
23 pub setup: Option<SetupConfig>,
24 /// the domain name of your instance (mandatory)
26 #[doku(example = "example.com")]
28 /// Address where lemmy should listen for incoming requests
29 #[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))]
30 #[doku(as = "String")]
32 /// Port where lemmy should listen for incoming requests
35 /// Whether the site is available over TLS. Needs to be true for federation to work.
37 pub tls_enabled: bool,
38 /// Set the URL for opentelemetry exports. If you do not have an opentelemetry collector, do not set this option
41 pub opentelemetry_url: Option<Url>,
44 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
46 pub struct PictrsConfig {
47 /// Address where pictrs is available (for image hosting)
48 #[default(Url::parse("http://pictrs:8080").expect("parse pictrs url"))]
49 #[doku(example = "http://pictrs:8080")]
52 /// Set a custom pictrs API key. ( Required for deleting images )
54 pub api_key: Option<String>,
57 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
59 pub struct DatabaseConfig {
60 /// Username to connect to postgres
62 pub(super) user: String,
63 /// Password to connect to postgres
64 #[default("password")]
66 #[default("localhost")]
67 /// Host where postgres is running
69 /// Port where postgres can be accessed
72 /// Name of the postgres database for lemmy
74 pub(super) database: String,
75 /// Maximum number of active sql connections
80 #[derive(Debug, Deserialize, Serialize, Clone, Document, SmartDefault)]
81 pub struct EmailConfig {
82 /// Hostname and port of the smtp server
83 #[doku(example = "localhost:25")]
84 pub smtp_server: String,
85 /// Login name for smtp server
86 pub smtp_login: Option<String>,
87 /// Password to login to the smtp server
88 pub smtp_password: Option<String>,
89 #[doku(example = "noreply@example.com")]
90 /// Address to send emails from, eg "noreply@your-instance.com"
91 pub smtp_from_address: String,
92 /// Whether or not smtp connections should use tls. Can be none, tls, or starttls
94 #[doku(example = "none")]
98 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
99 pub struct SetupConfig {
100 /// Username for the admin user
101 #[doku(example = "admin")]
102 pub admin_username: String,
103 /// Password for the admin user. It must be at least 10 characters.
104 #[doku(example = "tf6HHDS4RolWfFhk4Rq9")]
105 pub admin_password: String,
106 /// Name of the site (can be changed later)
107 #[doku(example = "My Lemmy Instance")]
108 pub site_name: String,
109 /// Email for the admin user (optional, can be omitted and set later through the website)
110 #[doku(example = "user@example.com")]
112 pub admin_email: Option<String>,