From ae4acc9568f7121bd25bbd3f076ea93b2f6907b3 Mon Sep 17 00:00:00 2001 From: Jade Ellis Date: Thu, 18 Dec 2025 22:15:28 +0000 Subject: [PATCH] fix: Don't incorrectly add thread root to relation response --- src/api/client/relations.rs | 34 +++------------------------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/src/api/client/relations.rs b/src/api/client/relations.rs index f65783e3..ba39bda7 100644 --- a/src/api/client/relations.rs +++ b/src/api/client/relations.rs @@ -168,35 +168,8 @@ async fn paginate_relations_with_filter( .collect() .await; - // For threads, check if we should include the root event - let mut root_event = None; - if is_thread && dir == Direction::Backward { - // Check if we've reached the beginning of the thread - // (fewer events than requested means we've exhausted the thread) - if events.len() < limit { - // Try to get the thread root event - if let Ok(root_pdu) = services.rooms.timeline.get_pdu(target).await { - // Check visibility - if services - .rooms - .state_accessor - .user_can_see_event(sender_user, room_id, target) - .await - { - // Store the root event to add to the response - root_event = Some(root_pdu); - } - } - } - } - // Determine if there are more events to fetch - let has_more = if root_event.is_some() { - false // We've included the root, no more events - } else { - // Check if we got a full page of results (might be more) - events.len() >= limit - }; + let has_more = events.len() >= limit; let next_batch = if has_more { match dir { @@ -208,11 +181,10 @@ async fn paginate_relations_with_filter( None }; - // Build the response chunk with thread root if needed - let chunk: Vec<_> = root_event + let chunk: Vec<_> = events .into_iter() + .map(at!(1)) .map(Event::into_format) - .chain(events.into_iter().map(at!(1)).map(Event::into_format)) .collect(); Ok(get_relating_events::v1::Response {