Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit bca64f9

Browse files
author
David Robertson
committed
Remove unused branch
I claim that it is impossible to hit the `continue` which is removed in this commit. Setup: - `events` is a list of all membership events in the range `since < time <= now`. - `non_joins` is the list of `e in events` with `e.membership` not equal to`"join"`. - `events` is a nonempty list by construction of `mem_change_events_by_room_id`. Rationale: - We hit the deleted code only if `non_joins` is empty. - If so, `events` consists only of `join` membership events. - `events` is non_empty, so there was at least one join during the sync period. - Therefore the room_id will belong to `sync_result_builder.joined_room_ids`. But this means we will have `continue`d in the branch above. - I'm assuming here that `joined_room_ids` and `events` are both using the same `now_token.room_key`.
1 parent 7aee344 commit bca64f9

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

synapse/handlers/sync.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ async def generate_sync_result(
10701070
At the end, we transfer data from the `sync_result_builder` to a new `SyncResult`
10711071
instance to signify that the sync calculation is complete.
10721072
"""
1073-
# NB: The now_token gets changed by some of the generate_sync_* methods,
1073+
# NB: Parts of the now_token get changed by some of the generate_sync_* methods,
10741074
# this is due to some of the underlying streams not supporting the ability
10751075
# to query up to a given point.
10761076
# Always use the `now_token` in `SyncResultBuilder`
@@ -1091,6 +1091,8 @@ async def generate_sync_result(
10911091
# See https://github.com/matrix-org/matrix-doc/issues/1144
10921092
raise NotImplementedError()
10931093
else:
1094+
# The `room_key` part of the `now_token` is not changed by the sync
1095+
# machinery. If it did, `joined_room_ids` could become out of date.
10941096
joined_room_ids = await self.get_rooms_for_user_at(
10951097
user_id, now_token.room_key
10961098
)
@@ -1837,10 +1839,6 @@ async def _classify_rooms_by_membership_changes(
18371839
if room_id in sync_result_builder.joined_room_ids:
18381840
continue
18391841

1840-
if not non_joins:
1841-
continue
1842-
last_non_join = non_joins[-1]
1843-
18441842
# Check if we have left the room. This can either be because we were
18451843
# joined before *or* that we since joined and then left.
18461844
if events[-1].membership != Membership.JOIN:
@@ -1861,6 +1859,7 @@ async def _classify_rooms_by_membership_changes(
18611859
newly_left_rooms.append(room_id)
18621860

18631861
# Only bother if we're still currently invited
1862+
last_non_join = non_joins[-1]
18641863
should_invite = last_non_join.membership == Membership.INVITE
18651864
if should_invite:
18661865
if last_non_join.sender not in ignored_users:

0 commit comments

Comments
 (0)