diff --git a/src/cfg.rs b/src/cfg.rs index 2947c06..781d70f 100755 --- a/src/cfg.rs +++ b/src/cfg.rs @@ -31,6 +31,7 @@ pub struct ServerCfg { pub struct SiteCfg { pub name: String, pub description: String, + pub default_noko: bool, } #[derive(Deserialize, Clone)] diff --git a/src/web/actions/create_post.rs b/src/web/actions/create_post.rs index 03151ea..b7ee830 100644 --- a/src/web/actions/create_post.rs +++ b/src/web/actions/create_post.rs @@ -66,7 +66,7 @@ pub async fn create_post( } let mut bumpy_bump = true; - let mut noko = true; + let mut noko = ctx.cfg.site.default_noko; let thread = match form.thread { Some(Text(thread)) => { @@ -143,12 +143,18 @@ pub async fn create_post( return Err(NekrochanError::EmailFormatError); } - if email_raw == "sage" || email_raw == "nonokosage" { + let email_lower = email_raw.to_lowercase(); + + if email_lower.contains("sage") { bumpy_bump = false; } - if email_raw == "nonoko" || email_raw == "nonokosage" { - noko = false; + if !ctx.cfg.site.default_noko && email_lower.contains("noko") { + noko = true + } + + if ctx.cfg.site.default_noko && email_lower.contains("nonoko") { + noko = false } Some(email_raw.into())