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

Commit

Permalink
Clarify use of content.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Oct 27, 2021
1 parent 2bb1462 commit 14a805c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions synapse/api/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,16 +327,19 @@ def check(self, event: FilterEvent) -> bool:
}
return self._check_fields(field_matchers)
else:
content = event.get("content")
# Content is assumed to be a dict below, so ensure it is. This should
# always be true for events, but account_data has been allowed to
# have non-dict content.
if not isinstance(content, dict):
content = {}

sender = event.get("sender", None)
content = event.get("content") or {}
if not sender:
# Presence events had their 'sender' in content.user_id, but are
# now handled above. We don't know if anything else uses this
# form. TODO: Check this and probably remove it.
# account_data has been allowed to have non-dict content, so
# check type first
if isinstance(content, dict):
sender = content.get("user_id")
sender = content.get("user_id")

room_id = event.get("room_id", None)
ev_type = event.get("type", None)
Expand Down

0 comments on commit 14a805c

Please sign in to comment.