]> Untitled Git - lemmy.git/commitdiff
Respect disable downvotes setting when federating
authorFelix Ableitner <me@nutomic.com>
Fri, 9 Oct 2020 13:41:40 +0000 (15:41 +0200)
committerFelix Ableitner <me@nutomic.com>
Fri, 9 Oct 2020 13:41:40 +0000 (15:41 +0200)
lemmy_apub/src/inbox/activities/dislike.rs

index dd63011d4df8383de82a0a67ea51412fe42cd2f2..06a7a00666490b7dd5521d283fad27cf03b15a8d 100644 (file)
@@ -16,6 +16,8 @@ use lemmy_db::{
   comment_view::CommentView,
   post::{PostForm, PostLike, PostLikeForm},
   post_view::PostView,
+  site::Site,
+  Crud,
   Likeable,
 };
 use lemmy_structs::{blocking, comment::CommentResponse, post::PostResponse};
@@ -30,6 +32,14 @@ pub async fn receive_dislike(
   activity: AnyBase,
   context: &LemmyContext,
 ) -> Result<HttpResponse, LemmyError> {
+  let enable_downvotes = blocking(context.pool(), move |conn| {
+    Site::read(conn, 1).map(|s| s.enable_downvotes)
+  })
+  .await??;
+  if !enable_downvotes {
+    return Ok(HttpResponse::Ok().finish());
+  }
+
   let dislike = Dislike::from_any_base(activity)?.context(location_info!())?;
   match dislike.object().as_single_kind_str() {
     Some("Page") => receive_dislike_post(dislike, context).await,