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

Commit

Permalink
Avoid raising errors due to malformed IDs in get_current_hosts_in_room
Browse files Browse the repository at this point in the history
Handle malformed user IDs with no colons in `get_current_hosts_in_room`.
It's not currently possible for a malformed user ID to join a room, so
this error would never be hit.

Signed-off-by: Sean Quah <seanq@matrix.org>
  • Loading branch information
Sean Quah committed Sep 8, 2022
1 parent b7e4bfd commit fc247f3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/13748.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid raising an error due to malformed user IDs in `get_current_hosts_in_room`. Malformed user IDs cannot currently join a room, so this error would not be hit.
3 changes: 3 additions & 0 deletions synapse/storage/databases/main/roommember.py
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,8 @@ async def get_current_hosts_in_room(self, room_id: str) -> List[str]:
# We use a `Set` just for fast lookups
domain_set: Set[str] = set()
for u in users:
if ":" not in u:
continue
domain = get_domain_from_id(u)
if domain not in domain_set:
domain_set.add(domain)
Expand Down Expand Up @@ -1071,6 +1073,7 @@ def get_current_hosts_in_room_txn(txn: LoggingTransaction) -> List[str]:
c.type = 'm.room.member'
AND c.membership = 'join'
AND c.room_id = ?
AND server_domain IS NOT NULL
/* Group all state events from the same domain into their own buckets (groups) */
GROUP BY server_domain
/* Sorted by lowest depth first */
Expand Down

0 comments on commit fc247f3

Please sign in to comment.