From 380f22720487807f1485851645a735f145920c7c Mon Sep 17 00:00:00 2001 From: Dessalines Date: Wed, 14 Feb 2024 11:12:28 -0500 Subject: [PATCH] Addressing PR comments. --- crates/api/src/post_report/create.rs | 1 - crates/api_common/src/utils.rs | 1 + crates/apub/src/activities/community/report.rs | 4 +++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/api/src/post_report/create.rs b/crates/api/src/post_report/create.rs index cda283af1..1327d7bb9 100644 --- a/crates/api/src/post_report/create.rs +++ b/crates/api/src/post_report/create.rs @@ -44,7 +44,6 @@ pub async fn create_post_report( ) .await?; - // Don't allow creating reports for removed / deleted posts check_post_deleted_or_removed(&post_view.post)?; let report_form = PostReportForm { diff --git a/crates/api_common/src/utils.rs b/crates/api_common/src/utils.rs index 85821a834..138364c84 100644 --- a/crates/api_common/src/utils.rs +++ b/crates/api_common/src/utils.rs @@ -225,6 +225,7 @@ pub async fn check_community_mod_action( Ok(()) } +/// Don't allow creating reports for removed / deleted posts pub fn check_post_deleted_or_removed(post: &Post) -> Result<(), LemmyError> { if post.deleted || post.removed { Err(LemmyErrorType::Deleted)? diff --git a/crates/apub/src/activities/community/report.rs b/crates/apub/src/activities/community/report.rs index 11941675a..97631d3c5 100644 --- a/crates/apub/src/activities/community/report.rs +++ b/crates/apub/src/activities/community/report.rs @@ -14,7 +14,7 @@ use activitypub_federation::{ kinds::activity::FlagType, traits::{ActivityHandler, Actor}, }; -use lemmy_api_common::context::LemmyContext; +use lemmy_api_common::{context::LemmyContext, utils::check_post_deleted_or_removed}; use lemmy_db_schema::{ source::{ activity::ActivitySendTargets, @@ -104,6 +104,8 @@ impl ActivityHandler for Report { let reason = self.reason()?; match self.object.dereference(context).await? { PostOrComment::Post(post) => { + check_post_deleted_or_removed(&post)?; + let report_form = PostReportForm { creator_id: actor.id, post_id: post.id,