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

Commit

Permalink
Global acct dat
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Feb 9, 2023
1 parent 4b3420e commit ab605e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 9 additions & 2 deletions synapse/api/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def __init__(self, hs: "HomeServer", filter_json: JsonDict):
hs, room_filter_json.get("account_data", {})
)
self._presence_filter = Filter(hs, filter_json.get("presence", {}))
self._account_data = Filter(hs, filter_json.get("account_data", {}))
self._account_data_filter = Filter(hs, filter_json.get("account_data", {}))

self.include_leave = filter_json.get("room", {}).get("include_leave", False)
self.event_fields = filter_json.get("event_fields", [])
Expand Down Expand Up @@ -259,7 +259,7 @@ async def filter_presence(
return await self._presence_filter.filter(presence_states)

async def filter_account_data(self, events: Iterable[JsonDict]) -> List[JsonDict]:
return await self._account_data.filter(events)
return await self._account_data_filter.filter(events)

async def filter_room_state(self, events: Iterable[EventBase]) -> List[EventBase]:
return await self._room_state_filter.filter(
Expand Down Expand Up @@ -294,6 +294,13 @@ def blocks_all_presence(self) -> bool:
or self._presence_filter.filters_all_senders()
)

def blocks_all_account_data(self) -> bool:
"""True if all global acount data will be filtered out."""
return (
self._account_data_filter.filters_all_types()
or self._account_data_filter.filters_all_senders()
)

def blocks_all_room_ephemeral(self) -> bool:
return (
self._room_ephemeral_filter.filters_all_types()
Expand Down
4 changes: 3 additions & 1 deletion synapse/handlers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,9 @@ async def generate_sync_result(

logger.debug("Fetching account data")

await self._generate_sync_entry_for_account_data(sync_result_builder)
# Account data is included if it is not filtered out.
if not sync_config.filter_collection.blocks_all_account_data():
await self._generate_sync_entry_for_account_data(sync_result_builder)

# Presence data is included if the server has it enabled and not filtered out.
include_presence_data = bool(
Expand Down

0 comments on commit ab605e5

Please sign in to comment.