X-Git-Url: http://these/git/?a=blobdiff_plain;f=crates%2Fapub%2Fsrc%2Factivities%2Fdeletion%2Fdelete.rs;h=95024c475c3c1b3ac609c03e9b6320d33bbcbb4f;hb=235cc8b22897bfb3e71ba3dbd725d36863fea8ba;hp=d2572590ad7a4691426e05671e3c678234933416;hpb=276a8c2bd3e4fd1323e66b808675cf14cf6f75c5;p=lemmy.git diff --git a/crates/apub/src/activities/deletion/delete.rs b/crates/apub/src/activities/deletion/delete.rs index d2572590..95024c47 100644 --- a/crates/apub/src/activities/deletion/delete.rs +++ b/crates/apub/src/activities/deletion/delete.rs @@ -4,6 +4,8 @@ use crate::{ deletion::{receive_delete_action, verify_delete_activity, DeletableObjects}, generate_activity_id, }, + check_apub_id_valid, + fetch_local_site_data, local_instance, objects::{community::ApubCommunity, person::ApubPerson}, protocol::{activities::deletion::delete::Delete, IdOrNestedObject}, @@ -14,8 +16,8 @@ use anyhow::anyhow; use lemmy_api_common::utils::blocking; use lemmy_db_schema::{ source::{ - comment::Comment, - community::Community, + comment::{Comment, CommentUpdateForm}, + community::{Community, CommunityUpdateForm}, moderator::{ ModRemoveComment, ModRemoveCommentForm, @@ -24,7 +26,7 @@ use lemmy_db_schema::{ ModRemovePost, ModRemovePostForm, }, - post::Post, + post::{Post, PostUpdateForm}, }, traits::Crud, }; @@ -55,6 +57,9 @@ impl ActivityHandler for Delete { context: &Data, request_counter: &mut i32, ) -> Result<(), LemmyError> { + let local_site_data = blocking(context.pool(), fetch_local_site_data).await??; + check_apub_id_valid(self.id(), &local_site_data, context.settings()) + .map_err(LemmyError::from_message)?; verify_delete_activity(self, self.summary.is_some(), context, request_counter).await?; Ok(()) } @@ -150,7 +155,11 @@ pub(in crate::activities) async fn receive_remove_action( }) .await??; let deleted_community = blocking(context.pool(), move |conn| { - Community::update_removed(conn, community.id, true) + Community::update( + conn, + community.id, + &CommunityUpdateForm::builder().removed(Some(true)).build(), + ) }) .await??; @@ -168,7 +177,11 @@ pub(in crate::activities) async fn receive_remove_action( }) .await??; let removed_post = blocking(context.pool(), move |conn| { - Post::update_removed(conn, post.id, true) + Post::update( + conn, + post.id, + &PostUpdateForm::builder().removed(Some(true)).build(), + ) }) .await??; @@ -186,7 +199,11 @@ pub(in crate::activities) async fn receive_remove_action( }) .await??; let removed_comment = blocking(context.pool(), move |conn| { - Comment::update_removed(conn, comment.id, true) + Comment::update( + conn, + comment.id, + &CommentUpdateForm::builder().removed(Some(true)).build(), + ) }) .await??;