Compare commits

...

1 commit

Author SHA1 Message Date
d733857145 WIP: partial solution for #1472 2021-03-02 18:02:42 +01:00
4 changed files with 76 additions and 6 deletions

76
Cargo.lock generated
View file

@ -904,8 +904,18 @@ version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858"
dependencies = [
"darling_core",
"darling_macro",
"darling_core 0.10.2",
"darling_macro 0.10.2",
]
[[package]]
name = "darling"
version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a06d4a9551359071d1890820e3571252b91229e0712e7c36b08940e603c5a8fc"
dependencies = [
"darling_core 0.12.2",
"darling_macro 0.12.2",
]
[[package]]
@ -918,7 +928,21 @@ dependencies = [
"ident_case",
"proc-macro2",
"quote",
"strsim",
"strsim 0.9.3",
"syn",
]
[[package]]
name = "darling_core"
version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b443e5fb0ddd56e0c9bfa47dc060c5306ee500cb731f2b91432dd65589a77684"
dependencies = [
"fnv",
"ident_case",
"proc-macro2",
"quote",
"strsim 0.10.0",
"syn",
]
@ -928,7 +952,18 @@ version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72"
dependencies = [
"darling_core",
"darling_core 0.10.2",
"quote",
"syn",
]
[[package]]
name = "darling_macro"
version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0220073ce504f12a70efc4e7cdaea9e9b1b324872e7ad96a208056d7a638b81"
dependencies = [
"darling_core 0.12.2",
"quote",
"syn",
]
@ -949,7 +984,7 @@ version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2658621297f2cf68762a6f7dc0bb7e1ff2cfd6583daef8ee0fed6f7ec468ec0"
dependencies = [
"darling",
"darling 0.10.2",
"derive_builder_core",
"proc-macro2",
"quote",
@ -962,7 +997,7 @@ version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2791ea3e372c8495c0bc2033991d76b512cd799d07491fbd6890124db9458bef"
dependencies = [
"darling",
"darling 0.10.2",
"proc-macro2",
"quote",
"syn",
@ -1982,6 +2017,7 @@ dependencies = [
"reqwest",
"serde",
"serde_json",
"serde_with",
"strum",
"strum_macros",
"thiserror",
@ -3061,6 +3097,28 @@ dependencies = [
"serde",
]
[[package]]
name = "serde_with"
version = "1.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b44be9227e214a0420707c9ca74c2d4991d9955bae9415a8f93f05cebf561be5"
dependencies = [
"serde",
"serde_with_macros",
]
[[package]]
name = "serde_with_macros"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e48b35457e9d855d3dc05ef32a73e0df1e2c0fd72c38796a4ee909160c8eeec2"
dependencies = [
"darling 0.12.2",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serial_test"
version = "0.5.1"
@ -3246,6 +3304,12 @@ version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c"
[[package]]
name = "strsim"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "strum"
version = "0.20.0"

View file

@ -37,3 +37,4 @@ jsonwebtoken = "7.2.0"
deser-hjson = "0.1.12"
merge = "0.1.0"
envy = "0.4.2"
serde_with = "1.6.4"

View file

@ -1,7 +1,10 @@
use merge::Merge;
use serde::Deserialize;
use serde_with::with_prefix;
use std::net::IpAddr;
with_prefix!(captcha "captcha__");
#[derive(Debug, Deserialize, Clone, Merge)]
pub struct Settings {
pub(crate) database: Option<DatabaseConfig>,
@ -14,6 +17,7 @@ pub struct Settings {
pub(crate) jwt_secret: Option<String>,
pub(crate) pictrs_url: Option<String>,
pub(crate) iframely_url: Option<String>,
#[serde(flatten, with = "captcha")]
pub(crate) captcha: Option<CaptchaConfig>,
pub(crate) email: Option<EmailConfig>,
pub(crate) setup: Option<SetupConfig>,

View file

@ -29,6 +29,7 @@ embed_migrations!();
async fn main() -> Result<(), LemmyError> {
env_logger::init();
let settings = Settings::get();
dbg!(&settings.captcha());
// Set up the r2d2 connection pool
let db_url = match get_database_url_from_env() {