mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-14 13:23:54 +01:00
Fix newly_left
rooms not appearing if we returned early (Sliding Sync) (#17301)
Fix `newly_left` rooms not appearing if we returned early when `membership_snapshot_token.is_before_or_eq(to_token.room_key)`. Introduced in https://github.com/element-hq/synapse/pull/17187 (part of Sliding Sync) The tests didn't catch it because they had a small typo in it `room_id1` vs `room_id2`. Found while working on https://github.com/element-hq/synapse/pull/17293
This commit is contained in:
parent
8c58eb7f17
commit
8aaff851b1
3 changed files with 15 additions and 14 deletions
1
changelog.d/17301.bugfix
Normal file
1
changelog.d/17301.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Add initial implementation of an experimental [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575) Sliding Sync `/sync` endpoint.
|
|
@ -275,12 +275,6 @@ class SlidingSyncHandler:
|
||||||
instance_map=immutabledict(instance_to_max_stream_ordering_map),
|
instance_map=immutabledict(instance_to_max_stream_ordering_map),
|
||||||
)
|
)
|
||||||
|
|
||||||
# If our `to_token` is already the same or ahead of the latest room membership
|
|
||||||
# for the user, we can just straight-up return the room list (nothing has
|
|
||||||
# changed)
|
|
||||||
if membership_snapshot_token.is_before_or_eq(to_token.room_key):
|
|
||||||
return sync_room_id_set
|
|
||||||
|
|
||||||
# Since we fetched the users room list at some point in time after the from/to
|
# Since we fetched the users room list at some point in time after the from/to
|
||||||
# tokens, we need to revert/rewind some membership changes to match the point in
|
# tokens, we need to revert/rewind some membership changes to match the point in
|
||||||
# time of the `to_token`. In particular, we need to make these fixups:
|
# time of the `to_token`. In particular, we need to make these fixups:
|
||||||
|
@ -300,14 +294,20 @@ class SlidingSyncHandler:
|
||||||
|
|
||||||
# 1) Fetch membership changes that fall in the range from `to_token` up to
|
# 1) Fetch membership changes that fall in the range from `to_token` up to
|
||||||
# `membership_snapshot_token`
|
# `membership_snapshot_token`
|
||||||
membership_change_events_after_to_token = (
|
#
|
||||||
await self.store.get_membership_changes_for_user(
|
# If our `to_token` is already the same or ahead of the latest room membership
|
||||||
user_id,
|
# for the user, we don't need to do any "2)" fix-ups and can just straight-up
|
||||||
from_key=to_token.room_key,
|
# use the room list from the snapshot as a base (nothing has changed)
|
||||||
to_key=membership_snapshot_token,
|
membership_change_events_after_to_token = []
|
||||||
excluded_rooms=self.rooms_to_exclude_globally,
|
if not membership_snapshot_token.is_before_or_eq(to_token.room_key):
|
||||||
|
membership_change_events_after_to_token = (
|
||||||
|
await self.store.get_membership_changes_for_user(
|
||||||
|
user_id,
|
||||||
|
from_key=to_token.room_key,
|
||||||
|
to_key=membership_snapshot_token,
|
||||||
|
excluded_rooms=self.rooms_to_exclude_globally,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
# 1) Assemble a list of the last membership events in some given ranges. Someone
|
# 1) Assemble a list of the last membership events in some given ranges. Someone
|
||||||
# could have left and joined multiple times during the given range but we only
|
# could have left and joined multiple times during the given range but we only
|
||||||
|
|
|
@ -326,7 +326,7 @@ class GetSyncRoomIdsForUserTestCase(HomeserverTestCase):
|
||||||
|
|
||||||
# Leave during the from_token/to_token range (newly_left)
|
# Leave during the from_token/to_token range (newly_left)
|
||||||
room_id2 = self.helper.create_room_as(user1_id, tok=user1_tok)
|
room_id2 = self.helper.create_room_as(user1_id, tok=user1_tok)
|
||||||
self.helper.leave(room_id1, user1_id, tok=user1_tok)
|
self.helper.leave(room_id2, user1_id, tok=user1_tok)
|
||||||
|
|
||||||
after_room2_token = self.event_sources.get_current_token()
|
after_room2_token = self.event_sources.get_current_token()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue