X-Git-Url: http://these/git/?a=blobdiff_plain;f=crates%2Fapi%2Fsrc%2Flocal_user%2Fget_captcha.rs;h=1d2511f56f9b79a55648e4b88f00438ee8a11d09;hb=235cc8b22897bfb3e71ba3dbd725d36863fea8ba;hp=b63550362a6b58461f18d5adbfbcf9a24a279dab;hpb=276a8c2bd3e4fd1323e66b808675cf14cf6f75c5;p=lemmy.git diff --git a/crates/api/src/local_user/get_captcha.rs b/crates/api/src/local_user/get_captcha.rs index b6355036..1d2511f5 100644 --- a/crates/api/src/local_user/get_captcha.rs +++ b/crates/api/src/local_user/get_captcha.rs @@ -2,8 +2,11 @@ use crate::{captcha_as_wav_base64, Perform}; use actix_web::web::Data; use captcha::{gen, Difficulty}; use chrono::Duration; -use lemmy_api_common::person::{CaptchaResponse, GetCaptcha, GetCaptchaResponse}; -use lemmy_db_schema::utils::naive_now; +use lemmy_api_common::{ + person::{CaptchaResponse, GetCaptcha, GetCaptchaResponse}, + utils::blocking, +}; +use lemmy_db_schema::{source::local_site::LocalSite, utils::naive_now}; use lemmy_utils::{error::LemmyError, ConnectionId}; use lemmy_websocket::{messages::CaptchaItem, LemmyContext}; @@ -17,13 +20,13 @@ impl Perform for GetCaptcha { context: &Data, _websocket_id: Option, ) -> Result { - let captcha_settings = &context.settings().captcha; + let local_site = blocking(context.pool(), LocalSite::read).await??; - if !captcha_settings.enabled { + if !local_site.captcha_enabled { return Ok(GetCaptchaResponse { ok: None }); } - let captcha = gen(match captcha_settings.difficulty.as_str() { + let captcha = gen(match local_site.captcha_difficulty.as_str() { "easy" => Difficulty::Easy, "hard" => Difficulty::Hard, _ => Difficulty::Medium,