From ec141bc69e46300b2823fcf9dd17d9ef5697b8e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sn=C3=ADda=C5=88ov=C3=BD=20Mistr?= Date: Mon, 15 Jan 2024 18:53:27 +0100 Subject: [PATCH] =?UTF-8?q?lep=C5=A1i=20syst=C3=A9m=20noko/sage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cfg.rs | 1 + src/web/actions/create_post.rs | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) 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())