diff --git a/changelog.d/+8b3a57647.bugfix.md b/changelog.d/+8b3a57647.bugfix.md new file mode 100644 index 000000000..df23044b6 --- /dev/null +++ b/changelog.d/+8b3a57647.bugfix.md @@ -0,0 +1 @@ +Fixed newly joined rooms failing to sync their full state (including the room name) to clients using legacy sync. diff --git a/src/api/client/sync/v3/joined.rs b/src/api/client/sync/v3/joined.rs index 20bcda294..ba46a0091 100644 --- a/src/api/client/sync/v3/joined.rs +++ b/src/api/client/sync/v3/joined.rs @@ -269,13 +269,22 @@ async fn build_state_and_timeline( ) .await?; - let (state_events, notification_counts, joined_since_last_sync) = try_join3( - build_state_events(services, sync_context, room_id, shortstatehashes, &timeline), + let (notification_counts, joined_since_last_sync) = try_join( build_notification_counts(services, sync_context, room_id, &timeline), check_joined_since_last_sync(services, shortstatehashes, sync_context), ) .await?; + let state_events = build_state_events( + services, + sync_context, + room_id, + shortstatehashes, + &timeline, + joined_since_last_sync, + ) + .await?; + // the timeline should always include at least one PDU if the syncing user // joined since the last sync, that being the syncing user's join event. if // it's empty something is wrong. @@ -459,6 +468,7 @@ async fn build_state_events( room_id: &RoomId, shortstatehashes: ShortStateHashes, timeline: &TimelinePdus, + joined_since_last_sync: bool, ) -> Result> { let SyncContext { syncing_user, @@ -488,9 +498,10 @@ async fn build_state_events( /* if `last_sync_end_count` is Some (meaning this is an incremental sync), and `last_sync_end_shortstatehash` is Some (meaning the syncing user didn't just join this room for the first time ever), and `full_state` is false, - then use `build_state_incremental`. + and the user didn't just join the room since the last sync, then use `build_state_incremental`. */ - | (Some(_), Some(last_sync_end_shortstatehash)) if !full_state => + | (Some(_), Some(last_sync_end_shortstatehash)) + if !full_state && !joined_since_last_sync => build_state_incremental( services, syncing_user,