]> Untitled Git - lemmy.git/blobdiff - crates/db_schema/src/impls/captcha_answer.rs
Make functions work with both connection and pool (#3420)
[lemmy.git] / crates / db_schema / src / impls / captcha_answer.rs
index de5fac65e235190fe1f19d31ca648b9d7baedf6d..fe85b78b28015d0385ff0ef1a275d7a6021ef008 100644 (file)
@@ -15,7 +15,7 @@ use diesel::{
 use diesel_async::RunQueryDsl;
 
 impl CaptchaAnswer {
-  pub async fn insert(pool: &DbPool, captcha: &CaptchaAnswerForm) -> Result<Self, Error> {
+  pub async fn insert(pool: &mut DbPool<'_>, captcha: &CaptchaAnswerForm) -> Result<Self, Error> {
     let conn = &mut get_conn(pool).await?;
 
     insert_into(captcha_answer)
@@ -24,7 +24,10 @@ impl CaptchaAnswer {
       .await
   }
 
-  pub async fn check_captcha(pool: &DbPool, to_check: CheckCaptchaAnswer) -> Result<bool, Error> {
+  pub async fn check_captcha(
+    pool: &mut DbPool<'_>,
+    to_check: CheckCaptchaAnswer,
+  ) -> Result<bool, Error> {
     let conn = &mut get_conn(pool).await?;
 
     // fetch requested captcha
@@ -57,6 +60,7 @@ mod tests {
   #[serial]
   async fn test_captcha_happy_path() {
     let pool = &build_db_pool_for_tests().await;
+    let pool = &mut pool.into();
 
     let inserted = CaptchaAnswer::insert(
       pool,
@@ -84,6 +88,7 @@ mod tests {
   #[serial]
   async fn test_captcha_repeat_answer_fails() {
     let pool = &build_db_pool_for_tests().await;
+    let pool = &mut pool.into();
 
     let inserted = CaptchaAnswer::insert(
       pool,