},
};
use lemmy_db_schema::{
- source::post::{Post, PostLike, PostLikeForm},
+ source::{
+ local_site::LocalSite,
+ post::{Post, PostLike, PostLikeForm},
+ },
traits::{Crud, Likeable},
};
-use lemmy_utils::{ConnectionId, LemmyError};
+use lemmy_utils::{error::LemmyError, ConnectionId};
use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperation};
#[async_trait::async_trait(?Send)]
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;
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"))?;