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

Commit e7b559d

Browse files
authored
Avoid unneeded work if auto-join rooms aren't configured. (#15262)
It is not necessary to reach out to the database to check some parameters if the auto-join rooms are not configured, or (in some cases) if auto-create rooms is not configured.
1 parent a1c9869 commit e7b559d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

changelog.d/15262.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Skip processing of auto-join room behaviour if there are not auto-join rooms configured.

synapse/handlers/register.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,14 +596,20 @@ async def _auto_join_rooms(self, user_id: str) -> None:
596596
Args:
597597
user_id: The user to join
598598
"""
599+
# If there are no rooms to auto-join, just bail.
600+
if not self.hs.config.registration.auto_join_rooms:
601+
return
602+
599603
# auto-join the user to any rooms we're supposed to dump them into
600604

601605
# try to create the room if we're the first real user on the server. Note
602606
# that an auto-generated support or bot user is not a real user and will never be
603607
# the user to create the room
604608
should_auto_create_rooms = False
605-
is_real_user = await self.store.is_real_user(user_id)
606-
if self.hs.config.registration.autocreate_auto_join_rooms and is_real_user:
609+
if (
610+
self.hs.config.registration.autocreate_auto_join_rooms
611+
and await self.store.is_real_user(user_id)
612+
):
607613
count = await self.store.count_real_users()
608614
should_auto_create_rooms = count == 1
609615

0 commit comments

Comments
 (0)