Skip to content

Commit

Permalink
Dont serve apub json for removed objects (ref #2522)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nutomic committed Nov 4, 2022
1 parent b5cd732 commit 5a3a9b4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion crates/apub/src/http/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down
10 changes: 9 additions & 1 deletion crates/apub/src/http/community.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion crates/apub/src/http/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down

0 comments on commit 5a3a9b4

Please sign in to comment.