diff --git a/src/web/actions/create_post.rs b/src/web/actions/create_post.rs index d9253c0..7ea635a 100644 --- a/src/web/actions/create_post.rs +++ b/src/web/actions/create_post.rs @@ -322,13 +322,15 @@ pub async fn check_spam( return Err(NekrochanError::FloodError); } - let last_thread: i64 = ctx.cache().get(format!("last_thread:{ip}")).await?; + let last_thread: Option = ctx.cache().get(format!("last_thread:{ip}")).await?; - let since_last_thread = Utc::now().timestamp_micros() - last_thread; - let since_last_thread = Duration::microseconds(since_last_thread); + if let Some(last_thread) = last_thread { + let since_last_thread = Utc::now().timestamp_micros() - last_thread; + let since_last_thread = Duration::microseconds(since_last_thread); - if since_last_thread.num_seconds() < board.config.thread_cooldown { - return Err(NekrochanError::FloodError); + if since_last_thread.num_seconds() < board.config.thread_cooldown { + return Err(NekrochanError::FloodError); + } } Ok(())