From 730920b57170746b9fdad25e8a0c512959627ec5 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sun, 27 Jul 2025 01:53:28 +0000 Subject: [PATCH] Collect v5 typing events concurrent with other extensions. Signed-off-by: Jason Volk --- src/api/client/sync/v5.rs | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/api/client/sync/v5.rs b/src/api/client/sync/v5.rs index 78b9535e..82af5b22 100644 --- a/src/api/client/sync/v5.rs +++ b/src/api/client/sync/v5.rs @@ -8,7 +8,7 @@ use std::{ use axum::extract::State; use futures::{ FutureExt, Stream, StreamExt, TryFutureExt, - future::{OptionFuture, join3, try_join4}, + future::{OptionFuture, join3, try_join5}, pin_mut, }; use ruma::{ @@ -139,17 +139,19 @@ pub(crate) async fn sync_events_v5_route( let to_device = collect_to_device(services, sync_info, next_batch).map(Ok); - let receipts = collect_receipts(services).map(Ok); + let receipts = collect_receipts(services, sync_info, next_batch).map(Ok); - let (account_data, e2ee, to_device, receipts) = - try_join4(account_data, e2ee, to_device, receipts).await?; + let typing = collect_typing_events(services, sync_info, next_batch, all_joined_rooms.clone()); + + let (account_data, e2ee, to_device, receipts, typing) = + try_join5(account_data, e2ee, to_device, receipts, typing).await?; let extensions = sync_events::v5::response::Extensions { account_data, e2ee, to_device, receipts, - typing: sync_events::v5::response::Typing::default(), + typing, }; let mut response = sync_events::v5::Response { @@ -172,9 +174,6 @@ pub(crate) async fn sync_events_v5_route( ) .await; - response.extensions.typing = - collect_typing_events(services, sender_user, &cached, all_joined_rooms.clone()).await?; - fetch_subscriptions(services, sync_info, &known_rooms, &mut todo_rooms).await; response.rooms = process_rooms( @@ -968,8 +967,8 @@ async fn collect_to_device( async fn collect_typing_events<'a, Rooms>( services: &Services, - sender_user: &UserId, - body: &sync_events::v5::Request, + (sender_user, _, _, body): SyncInfo<'_>, + _next_batch: u64, rooms: Rooms, ) -> Result where @@ -1007,7 +1006,11 @@ where .await } -async fn collect_receipts(_services: &Services) -> sync_events::v5::response::Receipts { +async fn collect_receipts( + _services: &Services, + (_sender_user, _, _globalsince, _body): SyncInfo<'_>, + _next_batch: u64, +) -> sync_events::v5::response::Receipts { sync_events::v5::response::Receipts { rooms: BTreeMap::new() } // TODO: get explicitly requested read receipts }