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

Commit

Permalink
Remove unused branch
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
David Robertson committed Dec 7, 2021
1 parent 7aee344 commit bca64f9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions synapse/handlers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ async def generate_sync_result(
At the end, we transfer data from the `sync_result_builder` to a new `SyncResult`
instance to signify that the sync calculation is complete.
"""
# NB: The now_token gets changed by some of the generate_sync_* methods,
# NB: Parts of the now_token get changed by some of the generate_sync_* methods,
# this is due to some of the underlying streams not supporting the ability
# to query up to a given point.
# Always use the `now_token` in `SyncResultBuilder`
Expand All @@ -1091,6 +1091,8 @@ async def generate_sync_result(
# See https://github.com/matrix-org/matrix-doc/issues/1144
raise NotImplementedError()
else:
# The `room_key` part of the `now_token` is not changed by the sync
# machinery. If it did, `joined_room_ids` could become out of date.
joined_room_ids = await self.get_rooms_for_user_at(
user_id, now_token.room_key
)
Expand Down Expand Up @@ -1837,10 +1839,6 @@ async def _classify_rooms_by_membership_changes(
if room_id in sync_result_builder.joined_room_ids:
continue

if not non_joins:
continue
last_non_join = non_joins[-1]

# Check if we have left the room. This can either be because we were
# joined before *or* that we since joined and then left.
if events[-1].membership != Membership.JOIN:
Expand All @@ -1861,6 +1859,7 @@ async def _classify_rooms_by_membership_changes(
newly_left_rooms.append(room_id)

# Only bother if we're still currently invited
last_non_join = non_joins[-1]
should_invite = last_non_join.membership == Membership.INVITE
if should_invite:
if last_non_join.sender not in ignored_users:
Expand Down

0 comments on commit bca64f9

Please sign in to comment.