]> Untitled Git - lemmy.git/blobdiff - crates/apub/src/activities/deletion/delete.rs
Automatically resolve report when post/comment is removed (#3850)
[lemmy.git] / crates / apub / src / activities / deletion / delete.rs
index 7a35ec5021cd054688acaf6514c91718224687ef..fa0a44aa38bcf1b7c2099fef7cc9a96435bf867a 100644 (file)
@@ -12,6 +12,7 @@ use lemmy_api_common::{context::LemmyContext, utils::sanitize_html_opt};
 use lemmy_db_schema::{
   source::{
     comment::{Comment, CommentUpdateForm},
+    comment_report::CommentReport,
     community::{Community, CommunityUpdateForm},
     moderator::{
       ModRemoveComment,
@@ -22,8 +23,9 @@ use lemmy_db_schema::{
       ModRemovePostForm,
     },
     post::{Post, PostUpdateForm},
+    post_report::PostReport,
   },
-  traits::Crud,
+  traits::{Crud, Reportable},
 };
 use lemmy_utils::error::{LemmyError, LemmyErrorType};
 use url::Url;
@@ -131,6 +133,7 @@ pub(in crate::activities) async fn receive_remove_action(
       .await?;
     }
     DeletableObjects::Post(post) => {
+      PostReport::resolve_all_for_object(&mut context.pool(), post.id, actor.id).await?;
       let form = ModRemovePostForm {
         mod_person_id: actor.id,
         post_id: post.id,
@@ -149,6 +152,7 @@ pub(in crate::activities) async fn receive_remove_action(
       .await?;
     }
     DeletableObjects::Comment(comment) => {
+      CommentReport::resolve_all_for_object(&mut context.pool(), comment.id, actor.id).await?;
       let form = ModRemoveCommentForm {
         mod_person_id: actor.id,
         comment_id: comment.id,