Skip to content

Commit

Permalink
Determine limited before filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
MadLittleMods committed Jun 19, 2024
1 parent 9883b0f commit ea2f8d4
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions synapse/handlers/sliding_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,17 +804,9 @@ async def get_room_sync_data(
# most recent).
timeline_events.reverse()

# Make sure we don't expose any events that the client shouldn't see
timeline_events = await filter_events_for_client(
self.storage_controllers,
user.to_string(),
timeline_events,
is_peeking=rooms_for_user_membership_at_to_token.membership
!= Membership.JOIN,
filter_send_to_client=True,
)

# Determine our `limited` status
# Determine our `limited` status based on the timeline. We do this before
# filtering the events so we can accurately determine if there is more to
# paginate even if we filter out some/all events.
if len(timeline_events) > room_sync_config.timeline_limit:
limited = True
# Get rid of that extra "+ 1" event because we only used it to determine
Expand All @@ -825,6 +817,19 @@ async def get_room_sync_data(
stream=timeline_events[0].internal_metadata.stream_ordering - 1
)

# TODO: Does `newly_joined` affect `limited`? It does in sync v2 but I fail
# to understand why.

# Make sure we don't expose any events that the client shouldn't see
timeline_events = await filter_events_for_client(
self.storage_controllers,
user.to_string(),
timeline_events,
is_peeking=rooms_for_user_membership_at_to_token.membership
!= Membership.JOIN,
filter_send_to_client=True,
)

# Determine how many "live" events we have (events within the given token range).
#
# This is mostly useful to determine whether a given @mention event should
Expand Down

0 comments on commit ea2f8d4

Please sign in to comment.