From a0a84d91cec9d734d0b9c14e748177c00cba0990 Mon Sep 17 00:00:00 2001 From: Nutomic Date: Sat, 5 Nov 2022 00:57:28 +0000 Subject: [PATCH] Dont serve apub json for removed objects (ref #2522) (#2538) --- crates/apub/src/http/comment.rs | 2 +- crates/apub/src/http/community.rs | 10 +++++++++- crates/apub/src/http/post.rs | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/apub/src/http/comment.rs b/crates/apub/src/http/comment.rs index 59cbee8e8..4a498a16a 100644 --- a/crates/apub/src/http/comment.rs +++ b/crates/apub/src/http/comment.rs @@ -30,7 +30,7 @@ pub(crate) async fn get_apub_comment( return Err(NotFound.into()); } - if !comment.deleted { + if !comment.deleted && !comment.removed { Ok(create_apub_response(&comment.into_apub(&**context).await?)) } else { Ok(create_apub_tombstone_response(comment.ap_id.clone())) diff --git a/crates/apub/src/http/community.rs b/crates/apub/src/http/community.rs index 6f68e8fc4..d4528236e 100644 --- a/crates/apub/src/http/community.rs +++ b/crates/apub/src/http/community.rs @@ -40,7 +40,7 @@ pub(crate) async fn get_apub_community_http( .await?? .into(); - if !community.deleted { + if !community.deleted && !community.removed { let apub = community.into_apub(&**context).await?; Ok(create_apub_response(&apub)) @@ -83,6 +83,10 @@ pub(crate) async fn get_apub_community_outbox( Community::read_from_name(conn, &info.community_name, false) }) .await??; + if community.deleted || community.removed { + return Err(LemmyError::from_message("deleted")); + } + let id = ObjectId::new(generate_outbox_url(&community.actor_id)?); let outbox_data = CommunityContext(community.into(), context.get_ref().clone()); let outbox: ApubCommunityOutbox = id @@ -101,6 +105,10 @@ pub(crate) async fn get_apub_community_moderators( }) .await?? .into(); + if community.deleted || community.removed { + return Err(LemmyError::from_message("deleted")); + } + let id = ObjectId::new(generate_outbox_url(&community.actor_id)?); let outbox_data = CommunityContext(community, context.get_ref().clone()); let moderators: ApubCommunityModerators = id diff --git a/crates/apub/src/http/post.rs b/crates/apub/src/http/post.rs index 0e321d176..5960db447 100644 --- a/crates/apub/src/http/post.rs +++ b/crates/apub/src/http/post.rs @@ -30,7 +30,7 @@ pub(crate) async fn get_apub_post( return Err(NotFound.into()); } - if !post.deleted { + if !post.deleted && !post.removed { Ok(create_apub_response(&post.into_apub(&context).await?)) } else { Ok(create_apub_tombstone_response(post.ap_id.clone()))