This commit is contained in:
Felix Ableitner 2024-09-30 16:11:43 +02:00
parent 84a18ec0a6
commit 8f19ba365e
2 changed files with 5 additions and 18 deletions

View File

@ -128,8 +128,6 @@ impl Object for ApubComment {
Ok(note) 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)] #[tracing::instrument(skip_all)]
async fn verify( async fn verify(
note: &Note, note: &Note,
@ -139,24 +137,14 @@ impl Object for ApubComment {
verify_domains_match(note.id.inner(), expected_domain)?; verify_domains_match(note.id.inner(), expected_domain)?;
verify_domains_match(note.attributed_to.inner(), note.id.inner())?; verify_domains_match(note.attributed_to.inner(), note.id.inner())?;
verify_is_public(&note.to, &note.cc)?; verify_is_public(&note.to, &note.cc)?;
let community = Box::pin(note.community(context)).await?; let community = note.community(context).await?;
Box::pin(check_apub_id_valid_with_strictness( check_apub_id_valid_with_strictness(note.id.inner(), community.local, context).await?;
note.id.inner(),
community.local,
context,
))
.await?;
verify_is_remote_object(&note.id, context)?; verify_is_remote_object(&note.id, context)?;
Box::pin(verify_person_in_community( verify_person_in_community(&note.attributed_to, &community, context).await?;
&note.attributed_to,
&community,
context,
))
.await?;
let (post, _) = Box::pin(note.get_parents(context)).await?; let (post, _) = note.get_parents(context).await?;
let creator = Box::pin(note.attributed_to.dereference(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) let is_mod_or_admin = is_mod_or_admin(&mut context.pool(), &creator, community.id)
.await .await
.is_ok(); .is_ok();

View File

@ -65,7 +65,6 @@ impl Note {
// some cases we have to fetch user profiles too, and reach the limit after only 25 comments // some cases we have to fetch user profiles too, and reach the limit after only 25 comments
// or so. // or so.
// A cleaner solution would be converting the recursion into a loop, but that is tricky. // 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 { if context.request_count() > MAX_COMMENT_DEPTH_LIMIT as u32 {
Err(LemmyErrorType::MaxCommentDepthReached)?; Err(LemmyErrorType::MaxCommentDepthReached)?;
} }