configurable honeypot toggle

This commit is contained in:
Lewis Wynne 2026-04-09 14:46:40 +01:00
parent 5bfba1b6ff
commit c3ceb39b71
3 changed files with 12 additions and 1 deletions

View file

@ -9,6 +9,7 @@ pub struct Config {
pub site_url: String,
pub telegram_bot_token: String,
pub telegram_chat_id: i64,
pub honeypot: bool,
}
impl Config {
@ -33,6 +34,9 @@ impl Config {
.map_err(|_| "BOOK_TELEGRAM_CHAT_ID is required")?
.parse()
.map_err(|_| "BOOK_TELEGRAM_CHAT_ID must be an integer")?,
honeypot: env::var("BOOK_HONEYPOT")
.map(|v| v != "false")
.unwrap_or(true),
})
}
}

View file

@ -53,7 +53,7 @@ async fn submit(
Form(form): Form<SubmitForm>,
) -> Html<String> {
// Honeypot check — silently discard
if !form.url.is_empty() {
if state.config.honeypot && !form.url.is_empty() {
return Html("Thanks! Your message is pending approval.".to_string());
}