Skip to content
Snippets Groups Projects
Unverified Commit f36da501 authored by Patrick Cloke's avatar Patrick Cloke Committed by GitHub
Browse files

Do not calculate presence or ephemeral events when they are filtered out (#14970)

This expands the previous optimisation from being only for initial
sync to being for all sync requests.

It also inverts some of the logic to be inclusive instead of exclusive.
parent 2186ebed
No related branches found
No related tags found
No related merge requests found
Improve performance of `/sync` in a few situations.
...@@ -1459,10 +1459,12 @@ class SyncHandler: ...@@ -1459,10 +1459,12 @@ class SyncHandler:
sync_result_builder, account_data_by_room sync_result_builder, account_data_by_room
) )
block_all_presence_data = ( # Presence data is included if the server has it enabled and not filtered out.
since_token is None and sync_config.filter_collection.blocks_all_presence() include_presence_data = (
self.hs_config.server.use_presence
and not sync_config.filter_collection.blocks_all_presence()
) )
if self.hs_config.server.use_presence and not block_all_presence_data: if include_presence_data:
logger.debug("Fetching presence data") logger.debug("Fetching presence data")
await self._generate_sync_entry_for_presence( await self._generate_sync_entry_for_presence(
sync_result_builder, sync_result_builder,
...@@ -1841,15 +1843,12 @@ class SyncHandler: ...@@ -1841,15 +1843,12 @@ class SyncHandler:
""" """
since_token = sync_result_builder.since_token since_token = sync_result_builder.since_token
# 1. Start by fetching all ephemeral events in rooms we've joined (if required).
user_id = sync_result_builder.sync_config.user.to_string() user_id = sync_result_builder.sync_config.user.to_string()
block_all_room_ephemeral = (
since_token is None
and sync_result_builder.sync_config.filter_collection.blocks_all_room_ephemeral()
)
if block_all_room_ephemeral: # 1. Start by fetching all ephemeral events in rooms we've joined (if required).
if (
sync_result_builder.sync_config.filter_collection.blocks_all_room_ephemeral()
):
ephemeral_by_room: Dict[str, List[JsonDict]] = {} ephemeral_by_room: Dict[str, List[JsonDict]] = {}
else: else:
now_token, ephemeral_by_room = await self.ephemeral_by_room( now_token, ephemeral_by_room = await self.ephemeral_by_room(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment