mirror of
https://github.com/element-hq/synapse.git
synced 2026-11-04 11:17:51 +00:00
Send server announcement rooms with what they missed while left out
A sender removed before anything was announced gets the synthetic join, then the room is left out of their lists until the first announcement. It was dropped from the rooms checked for updates outside the lists, so the connection kept it as sent up to its last token: when the announcement listed it again, only that announcement went down and any change made in between, such as a new room name, was lost. The rooms left out are now kept among the rooms checked for updates, without being listed. A change while they are left out marks them as only partly sent, and they come back with everything since. This reuses the existing tracking of rooms outside the list ranges, instead of resending the room from scratch when it is listed again, which would need its own bookkeeping.
This commit is contained in:
2 files changed
+32
-2
No files matched your search
@@ -144,6 +144,8 @@ class SlidingSyncInterestedRooms:
|
||||
_interested_ in (in a pure sense),
|
||||
even if these rooms are omitted from the current window (which
|
||||
is, in a sense, just a computational optimisation).
|
||||
It also includes the server announcement rooms left out of the lists for
|
||||
now, so that their updates are recorded until they are listed again.
|
||||
"""
|
||||
|
||||
room_membership_for_user_map: Mapping[str, RoomsForUserType]
|
||||
@@ -769,7 +771,7 @@ class SlidingSyncRoomLists:
|
||||
lists=lists,
|
||||
relevant_room_map=relevant_room_map,
|
||||
relevant_rooms_to_send_map=relevant_rooms_to_send_map,
|
||||
all_rooms=all_rooms,
|
||||
all_rooms=all_rooms | hidden_room_ids,
|
||||
room_membership_for_user_map=room_membership_for_user_map,
|
||||
newly_joined_rooms=newly_joined_room_ids,
|
||||
newly_left_rooms=newly_left_room_map.keys()
|
||||
@@ -972,7 +974,7 @@ class SlidingSyncRoomLists:
|
||||
lists=lists,
|
||||
relevant_room_map=relevant_room_map,
|
||||
relevant_rooms_to_send_map=relevant_rooms_to_send_map,
|
||||
all_rooms=all_rooms,
|
||||
all_rooms=all_rooms | hidden_room_ids,
|
||||
room_membership_for_user_map=room_membership_for_user_map,
|
||||
newly_joined_rooms=newly_joined_room_ids,
|
||||
newly_left_rooms=newly_left_room_ids - server_announcement_room_map.keys(),
|
||||
|
||||
@@ -333,6 +333,34 @@ class SlidingSyncServerAnnouncementsTestCase(SlidingSyncBase):
|
||||
|
||||
self._assert_not_delivered(response)
|
||||
|
||||
def test_removed_member_room_changed_while_left_out(self) -> None:
|
||||
"""A member removed from the configured senders before anything was
|
||||
announced gets the room's new name with the first announcement, when the
|
||||
name changed while the room was left out of their lists.
|
||||
"""
|
||||
sync_body = self._sync_body(timeline_limit=5)
|
||||
_, pos = self.do_sync(sync_body, tok=self.former_tok)
|
||||
self._remove_former()
|
||||
_, pos = self.do_sync(sync_body, since=pos, tok=self.former_tok)
|
||||
self.config.rooms = [attr.evolve(self.config.rooms[0], room_name="New name")]
|
||||
self.get_success(self.handler.reconcile_rooms())
|
||||
response, pos = self.do_sync(sync_body, since=pos, tok=self.former_tok)
|
||||
self._assert_not_delivered(response)
|
||||
self._announce("hello")
|
||||
|
||||
response, _ = self.do_sync(sync_body, since=pos, tok=self.former_tok)
|
||||
|
||||
room = response["rooms"][self.room_id]
|
||||
self.assertEqual(room.get("name"), "New name")
|
||||
self.assertEqual(
|
||||
[
|
||||
event["content"]["name"]
|
||||
for event in room.get("required_state", [])
|
||||
if event["type"] == EventTypes.Name
|
||||
],
|
||||
["New name"],
|
||||
)
|
||||
|
||||
def test_removed_member_existing_connection(self) -> None:
|
||||
"""A member removed from the configured senders while their connection is
|
||||
open gets the synthetic join instead of their kick, even before anything
|
||||
|
||||
Reference in new issue
Block a user