skip left/invited rooms with no updates in /sync

Before this change we were just returning an empty object for left or
invited rooms that don't have any updates. This is valid coloredding to
the spec, but it's a nicer to debug if they are omitted it and results in
a little less network traffic. For joined rooms, we are already skipping
empty updates.

With filtering support, it's much more common to have sync responses where
many rooms are empty, because all of the state/timeline events may be
filtered out.
This commit is contained in:
Benjamin Lee 2024-05-03 17:15:59 -07:00
parent 4b6e2fae52
commit 0aae761da4
No known key found for this signature in database
GPG key ID: FB9624E2885D55A4

View file

@ -460,16 +460,16 @@ async fn sync_helper(
}
};
left_rooms.insert(
room_id.into_owned(),
LeftRoom {
account_data: RoomAccountData {
events: Vec::new(),
},
timeline,
state,
let left_room = LeftRoom {
account_data: RoomAccountData {
events: Vec::new(),
},
);
timeline,
state,
};
if !left_room.is_empty() {
left_rooms.insert(room_id.into_owned(), left_room);
}
}
let mut invited_rooms = BTreeMap::new();
@ -519,14 +519,14 @@ async fn sync_helper(
continue;
}
invited_rooms.insert(
room_id.into_owned(),
InvitedRoom {
invite_state: InviteState {
events: invite_state_events,
},
let invited_room = InvitedRoom {
invite_state: InviteState {
events: invite_state_events,
},
);
};
if !invited_room.is_empty() {
invited_rooms.insert(room_id.into_owned(), invited_room);
}
}
for user_id in left_encrypted_users {