diff --git a/src/api/client_server/sync/msc4186.rs b/src/api/client_server/sync/msc4186.rs index 9d8aef8f..7c7cee3a 100644 --- a/src/api/client_server/sync/msc4186.rs +++ b/src/api/client_server/sync/msc4186.rs @@ -499,9 +499,31 @@ pub(crate) async fn sync_events_v5_route( } } + let extensions = sync_events::v5::response::Extensions { + to_device, + e2ee: e2ee.unwrap_or_default(), + account_data: account_data.unwrap_or_default(), + receipts: sync_events::v5::response::Receipts { + rooms: BTreeMap::new(), + }, + typing: sync_events::v5::response::Typing { + rooms: BTreeMap::new(), + }, + }; + + let extensions_empty = extensions + .to_device + .as_ref() + .is_none_or(|to_device| to_device.events.is_empty()) + && extensions.e2ee.device_lists.is_empty() + && extensions.account_data.is_empty() + && extensions.receipts.is_empty() + && extensions.typing.is_empty(); + if rooms .iter() .all(|(_, r)| r.timeline.is_empty() && r.required_state.is_empty()) + && extensions_empty { // Hang a few seconds so requests are not spammed // Stop hanging if new info arrives @@ -520,17 +542,7 @@ pub(crate) async fn sync_events_v5_route( pos: next_batch.to_string(), lists, rooms, - extensions: sync_events::v5::response::Extensions { - to_device, - e2ee: e2ee.unwrap_or_default(), - account_data: account_data.unwrap_or_default(), - receipts: sync_events::v5::response::Receipts { - rooms: BTreeMap::new(), - }, - typing: sync_events::v5::response::Typing { - rooms: BTreeMap::new(), - }, - }, + extensions, })) }