]> Untitled Git - lemmy.git/blobdiff - crates/api/src/local_user/get_captcha.rs
Make functions work with both connection and pool (#3420)
[lemmy.git] / crates / api / src / local_user / get_captcha.rs
index 1330442488ccf48b56eaa1652c20f069ff862b72..5f1079ef238851deda151092208df357094ffdc3 100644 (file)
@@ -17,7 +17,7 @@ impl Perform for GetCaptcha {
 
   #[tracing::instrument(skip(context))]
   async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
-    let local_site = LocalSite::read(context.pool()).await?;
+    let local_site = LocalSite::read(&mut context.pool()).await?;
 
     if !local_site.captcha_enabled {
       return Ok(GetCaptchaResponse { ok: None });
@@ -33,11 +33,11 @@ impl Perform for GetCaptcha {
 
     let png = captcha.as_base64().expect("failed to generate captcha");
 
-    let wav = captcha_as_wav_base64(&captcha);
+    let wav = captcha_as_wav_base64(&captcha)?;
 
     let captcha_form: CaptchaAnswerForm = CaptchaAnswerForm { answer };
     // Stores the captcha item in the db
-    let captcha = CaptchaAnswer::insert(context.pool(), &captcha_form).await?;
+    let captcha = CaptchaAnswer::insert(&mut context.pool(), &captcha_form).await?;
 
     Ok(GetCaptchaResponse {
       ok: Some(CaptchaResponse {