]> Untitled Git - lemmy.git/blobdiff - crates/api/src/post/like.rs
Moving settings to Database. (#2492)
[lemmy.git] / crates / api / src / post / like.rs
index 5197225602bc290fd5f86f275d47e6e33ba872bf..ee29a021f8ea71c56c7770d8c92f7584fd8e5f08 100644 (file)
@@ -20,7 +20,10 @@ use lemmy_apub::{
   },
 };
 use lemmy_db_schema::{
-  source::post::{Post, PostLike, PostLikeForm},
+  source::{
+    local_site::LocalSite,
+    post::{Post, PostLike, PostLikeForm},
+  },
   traits::{Crud, Likeable},
 };
 use lemmy_utils::{error::LemmyError, ConnectionId};
@@ -39,9 +42,10 @@ impl Perform for CreatePostLike {
     let data: &CreatePostLike = self;
     let local_user_view =
       get_local_user_view_from_jwt(&data.auth, context.pool(), context.secret()).await?;
+    let local_site = blocking(context.pool(), LocalSite::read).await??;
 
     // Don't do a downvote if site has downvotes disabled
-    check_downvotes_enabled(data.score, context.pool()).await?;
+    check_downvotes_enabled(data.score, &local_site)?;
 
     // Check for a community ban
     let post_id = data.post_id;
@@ -72,7 +76,7 @@ impl Perform for CreatePostLike {
     let do_add = like_form.score != 0 && (like_form.score == 1 || like_form.score == -1);
     if do_add {
       let like_form2 = like_form.clone();
-      let like = move |conn: &'_ _| PostLike::like(conn, &like_form2);
+      let like = move |conn: &mut _| PostLike::like(conn, &like_form2);
       blocking(context.pool(), like)
         .await?
         .map_err(|e| LemmyError::from_error_message(e, "couldnt_like_post"))?;