mirror of
https://github.com/element-hq/synapse
synced 2024-07-07 00:53:29 +00:00
Determine limited before filtering
This commit is contained in:
parent
9883b0f63f
commit
1c06153a0d
|
@ -804,17 +804,9 @@ class SlidingSyncHandler:
|
||||||
# most recent).
|
# most recent).
|
||||||
timeline_events.reverse()
|
timeline_events.reverse()
|
||||||
|
|
||||||
# Make sure we don't expose any events that the client shouldn't see
|
# Determine our `limited` status based on the timeline. We do this before
|
||||||
timeline_events = await filter_events_for_client(
|
# filtering the events so we can accurately determine if there is more to
|
||||||
self.storage_controllers,
|
# paginate even if we filter out some/all events.
|
||||||
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
|
|
||||||
if len(timeline_events) > room_sync_config.timeline_limit:
|
if len(timeline_events) > room_sync_config.timeline_limit:
|
||||||
limited = True
|
limited = True
|
||||||
# Get rid of that extra "+ 1" event because we only used it to determine
|
# Get rid of that extra "+ 1" event because we only used it to determine
|
||||||
|
@ -825,6 +817,19 @@ class SlidingSyncHandler:
|
||||||
stream=timeline_events[0].internal_metadata.stream_ordering - 1
|
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).
|
# 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
|
# This is mostly useful to determine whether a given @mention event should
|
||||||
|
|
|
@ -1874,6 +1874,13 @@ class SlidingSyncTestCase(unittest.HomeserverTestCase):
|
||||||
[],
|
[],
|
||||||
channel.json_body["rooms"][room_id1]["timeline"],
|
channel.json_body["rooms"][room_id1]["timeline"],
|
||||||
)
|
)
|
||||||
|
# Even though we don't get any timeline events because they are filtered out,
|
||||||
|
# there is still more to paginate
|
||||||
|
self.assertEqual(
|
||||||
|
channel.json_body["rooms"][room_id1]["limited"],
|
||||||
|
True,
|
||||||
|
channel.json_body["rooms"][room_id1],
|
||||||
|
)
|
||||||
# We should have some `stripped_state` so the potential joiner can identify the
|
# We should have some `stripped_state` so the potential joiner can identify the
|
||||||
# room (we don't care about the order).
|
# room (we don't care about the order).
|
||||||
self.assertCountEqual(
|
self.assertCountEqual(
|
||||||
|
@ -1906,3 +1913,4 @@ class SlidingSyncTestCase(unittest.HomeserverTestCase):
|
||||||
],
|
],
|
||||||
channel.json_body["rooms"][room_id1]["invite_state"],
|
channel.json_body["rooms"][room_id1]["invite_state"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue