X-Git-Url: http://these/git/?a=blobdiff_plain;f=crates%2Fapub%2Fsrc%2Factivities%2Fdeletion%2Fundo_delete.rs;h=f73c780c2de38670340d54a61f00fac5fe860786;hb=235cc8b22897bfb3e71ba3dbd725d36863fea8ba;hp=c43e4d87194c47a05c6b61663acf2be4fa81942f;hpb=276a8c2bd3e4fd1323e66b808675cf14cf6f75c5;p=lemmy.git diff --git a/crates/apub/src/activities/deletion/undo_delete.rs b/crates/apub/src/activities/deletion/undo_delete.rs index c43e4d87..f73c780c 100644 --- a/crates/apub/src/activities/deletion/undo_delete.rs +++ b/crates/apub/src/activities/deletion/undo_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, undo_delete::UndoDelete}, @@ -13,8 +15,8 @@ use activitystreams_kinds::activity::UndoType; use lemmy_api_common::utils::blocking; use lemmy_db_schema::{ source::{ - comment::Comment, - community::Community, + comment::{Comment, CommentUpdateForm}, + community::{Community, CommunityUpdateForm}, moderator::{ ModRemoveComment, ModRemoveCommentForm, @@ -23,7 +25,7 @@ use lemmy_db_schema::{ ModRemovePost, ModRemovePostForm, }, - post::Post, + post::{Post, PostUpdateForm}, }, traits::Crud, }; @@ -54,6 +56,9 @@ impl ActivityHandler for UndoDelete { 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)?; self.object.verify(context, request_counter).await?; verify_delete_activity( &self.object, @@ -148,7 +153,11 @@ impl UndoDelete { }) .await??; let deleted_community = blocking(context.pool(), move |conn| { - Community::update_removed(conn, community.id, false) + Community::update( + conn, + community.id, + &CommunityUpdateForm::builder().removed(Some(false)).build(), + ) }) .await??; send_community_ws_message(deleted_community.id, EditCommunity, None, None, context).await?; @@ -165,7 +174,11 @@ impl UndoDelete { }) .await??; let removed_post = blocking(context.pool(), move |conn| { - Post::update_removed(conn, post.id, false) + Post::update( + conn, + post.id, + &PostUpdateForm::builder().removed(Some(false)).build(), + ) }) .await??; send_post_ws_message(removed_post.id, EditPost, None, None, context).await?; @@ -182,7 +195,11 @@ impl UndoDelete { }) .await??; let removed_comment = blocking(context.pool(), move |conn| { - Comment::update_removed(conn, comment.id, false) + Comment::update( + conn, + comment.id, + &CommentUpdateForm::builder().removed(Some(false)).build(), + ) }) .await??; send_comment_ws_message_simple(removed_comment.id, EditComment, context).await?;