From 8f19ba365eb3e78d80ff1781066fab937b1e62a2 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Mon, 30 Sep 2024 16:11:43 +0200 Subject: [PATCH] cleanup --- crates/apub/src/objects/comment.rs | 22 +++++----------------- crates/apub/src/protocol/objects/note.rs | 1 - 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/crates/apub/src/objects/comment.rs b/crates/apub/src/objects/comment.rs index 2658ab305..ad7d84a6f 100644 --- a/crates/apub/src/objects/comment.rs +++ b/crates/apub/src/objects/comment.rs @@ -128,8 +128,6 @@ impl Object for ApubComment { Ok(note) } - /// Recursively fetches all parent comments. This can lead to a stack overflow so we need to - /// Box::pin all large futures on the heap. #[tracing::instrument(skip_all)] async fn verify( note: &Note, @@ -139,24 +137,14 @@ impl Object for ApubComment { verify_domains_match(note.id.inner(), expected_domain)?; verify_domains_match(note.attributed_to.inner(), note.id.inner())?; verify_is_public(¬e.to, ¬e.cc)?; - let community = Box::pin(note.community(context)).await?; + let community = note.community(context).await?; - Box::pin(check_apub_id_valid_with_strictness( - note.id.inner(), - community.local, - context, - )) - .await?; + check_apub_id_valid_with_strictness(note.id.inner(), community.local, context).await?; verify_is_remote_object(¬e.id, context)?; - Box::pin(verify_person_in_community( - ¬e.attributed_to, - &community, - context, - )) - .await?; + verify_person_in_community(¬e.attributed_to, &community, context).await?; - let (post, _) = Box::pin(note.get_parents(context)).await?; - let creator = Box::pin(note.attributed_to.dereference(context)).await?; + let (post, _) = note.get_parents(context).await?; + let creator = note.attributed_to.dereference(context).await?; let is_mod_or_admin = is_mod_or_admin(&mut context.pool(), &creator, community.id) .await .is_ok(); diff --git a/crates/apub/src/protocol/objects/note.rs b/crates/apub/src/protocol/objects/note.rs index 2f97c6abc..e3e204254 100644 --- a/crates/apub/src/protocol/objects/note.rs +++ b/crates/apub/src/protocol/objects/note.rs @@ -65,7 +65,6 @@ impl Note { // some cases we have to fetch user profiles too, and reach the limit after only 25 comments // or so. // A cleaner solution would be converting the recursion into a loop, but that is tricky. - // Use a lower request limit here. Otherwise we can run into stack overflow due to recursion. if context.request_count() > MAX_COMMENT_DEPTH_LIMIT as u32 { Err(LemmyErrorType::MaxCommentDepthReached)?; }