diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2021-07-13 08:59:27 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-13 08:59:27 -0400 |
commit | 2d16e69b4bf09b5274a8fa15c8ca4719db8366c1 (patch) | |
tree | 64295c8acdff001ba839adb82ab29f6baa3972ab /synapse/storage | |
parent | Merge branch 'master' into develop (diff) | |
download | synapse-2d16e69b4bf09b5274a8fa15c8ca4719db8366c1.tar.xz |
Show all joinable rooms in the spaces summary. (#10298)
Previously only world-readable rooms were shown. This means that rooms which are public, knockable, or invite-only with a pending invitation, are included in a space summary. It also applies the same logic to the experimental room version from MSC3083 -- if a user has access to the proper allowed rooms then it is shown in the spaces summary. This change is made per MSC3173 allowing stripped state of a room to be shown to any potential room joiner.
Diffstat (limited to 'synapse/storage')
-rw-r--r-- | synapse/storage/databases/main/roommember.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/synapse/storage/databases/main/roommember.py b/synapse/storage/databases/main/roommember.py index 2796354a1f..4d82c4c26d 100644 --- a/synapse/storage/databases/main/roommember.py +++ b/synapse/storage/databases/main/roommember.py @@ -703,13 +703,22 @@ class RoomMemberWorkerStore(EventsWorkerStore): @cached(max_entries=10000) async def is_host_joined(self, room_id: str, host: str) -> bool: + return await self._check_host_room_membership(room_id, host, Membership.JOIN) + + @cached(max_entries=10000) + async def is_host_invited(self, room_id: str, host: str) -> bool: + return await self._check_host_room_membership(room_id, host, Membership.INVITE) + + async def _check_host_room_membership( + self, room_id: str, host: str, membership: str + ) -> bool: if "%" in host or "_" in host: raise Exception("Invalid host name") sql = """ SELECT state_key FROM current_state_events AS c INNER JOIN room_memberships AS m USING (event_id) - WHERE m.membership = 'join' + WHERE m.membership = ? AND type = 'm.room.member' AND c.room_id = ? AND state_key LIKE ? @@ -722,7 +731,7 @@ class RoomMemberWorkerStore(EventsWorkerStore): like_clause = "%:" + host rows = await self.db_pool.execute( - "is_host_joined", None, sql, room_id, like_clause + "is_host_joined", None, sql, membership, room_id, like_clause ) if not rows: |