From 78ae9b3f4718fe60c3005040ced0eb11abcda2a0 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Tue, 23 Aug 2022 15:34:33 -0500 Subject: [PATCH 1/3] Use dedidcated `get_local_users_in_room` when finding local users Found while working on https://github.com/matrix-org/synapse/pull/13575#discussion_r953023755 --- synapse/handlers/event_auth.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/synapse/handlers/event_auth.py b/synapse/handlers/event_auth.py index a2dd9c7efabf..c3ddc5d18253 100644 --- a/synapse/handlers/event_auth.py +++ b/synapse/handlers/event_auth.py @@ -129,12 +129,9 @@ async def get_user_which_could_invite( else: users = {} - # Find the user with the highest power level. - users_in_room = await self._store.get_users_in_room(room_id) - # Only interested in local users. - local_users_in_room = [ - u for u in users_in_room if get_domain_from_id(u) == self._server_name - ] + # Find the user with the highest power level (only interested in local + # users). + local_users_in_room = await self._store.get_local_users_in_room(room_id) chosen_user = max( local_users_in_room, key=lambda user: users.get(user, users_default_level), From 186f1384146e045790879905b901dc2a369d4955 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Tue, 23 Aug 2022 15:38:52 -0500 Subject: [PATCH 2/3] Add changelog --- changelog.d/13606.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/13606.misc diff --git a/changelog.d/13606.misc b/changelog.d/13606.misc new file mode 100644 index 000000000000..08a90fa33ecd --- /dev/null +++ b/changelog.d/13606.misc @@ -0,0 +1 @@ +Use dedicated `get_local_users_in_room` to find local users when calculating `join_authorised_via_users_server` of a `/make_join` request. From d1907c1eca54f686e0d7ccfde9d60feff09adb1c Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Tue, 23 Aug 2022 15:41:11 -0500 Subject: [PATCH 3/3] Better changelog --- changelog.d/13606.misc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/13606.misc b/changelog.d/13606.misc index 08a90fa33ecd..58a44677989a 100644 --- a/changelog.d/13606.misc +++ b/changelog.d/13606.misc @@ -1 +1 @@ -Use dedicated `get_local_users_in_room` to find local users when calculating `join_authorised_via_users_server` of a `/make_join` request. +Use dedicated `get_local_users_in_room(room_id)` function to find local users when calculating `join_authorised_via_users_server` of a `/make_join` request.