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

Commit

Permalink
Make room_member_handler a member of RoomCreationHandler
Browse files Browse the repository at this point in the history
... to save passing it into `_send_events_for_new_room`
  • Loading branch information
richvdh committed Oct 25, 2018
1 parent 871c4ab commit 7f7b2cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
6 changes: 4 additions & 2 deletions synapse/handlers/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def __init__(self, hs):
self._auth_handler = hs.get_auth_handler()
self.profile_handler = hs.get_profile_handler()
self.user_directory_handler = hs.get_user_directory_handler()
self.room_creation_handler = self.hs.get_room_creation_handler()
self.captcha_client = CaptchaServerHttpClient(hs)

self._next_generated_user_id = None
Expand Down Expand Up @@ -241,7 +240,10 @@ def register(
else:
# create room expects the localpart of the room alias
room_alias_localpart = room_alias.localpart
yield self.room_creation_handler.create_room(

# getting the RoomCreationHandler during init gives a dependency
# loop
yield self.hs.get_room_creation_handler().create_room(
fake_requester,
config={
"preset": "public_chat",
Expand Down
9 changes: 3 additions & 6 deletions synapse/handlers/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def __init__(self, hs):

self.spam_checker = hs.get_spam_checker()
self.event_creation_handler = hs.get_event_creation_handler()
self.room_member_handler = hs.get_room_member_handler()

@defer.inlineCallbacks
def create_room(self, requester, config, ratelimit=True,
Expand Down Expand Up @@ -195,12 +196,9 @@ def create_room(self, requester, config, ratelimit=True,
# override any attempt to set room versions via the creation_content
creation_content["room_version"] = room_version

room_member_handler = self.hs.get_room_member_handler()

yield self._send_events_for_new_room(
requester,
room_id,
room_member_handler,
preset_config=preset_config,
invite_list=invite_list,
initial_state=initial_state,
Expand Down Expand Up @@ -242,7 +240,7 @@ def create_room(self, requester, config, ratelimit=True,
if is_direct:
content["is_direct"] = is_direct

yield room_member_handler.update_membership(
yield self.room_member_handler.update_membership(
requester,
UserID.from_string(invitee),
room_id,
Expand Down Expand Up @@ -280,7 +278,6 @@ def _send_events_for_new_room(
self,
creator, # A Requester object.
room_id,
room_member_handler,
preset_config,
invite_list,
initial_state,
Expand Down Expand Up @@ -325,7 +322,7 @@ def send(etype, content, **kwargs):
content=creation_content,
)

yield room_member_handler.update_membership(
yield self.room_member_handler.update_membership(
creator,
creator.user,
room_id,
Expand Down

0 comments on commit 7f7b2cd

Please sign in to comment.