@@ -690,13 +690,14 @@ async def create_room(
690690 config : JsonDict ,
691691 ratelimit : bool = True ,
692692 creator_join_profile : Optional [JsonDict ] = None ,
693- ) -> Tuple [dict , int ]:
693+ ) -> Tuple [str , Optional [ RoomAlias ] , int ]:
694694 """Creates a new room.
695695
696696 Args:
697- requester:
698- The user who requested the room creation.
699- config : A dict of configuration options.
697+ requester: The user who requested the room creation.
698+ config: A dict of configuration options. This will be the body of
699+ a /createRoom request; see
700+ https://spec.matrix.org/latest/client-server-api/#post_matrixclientv3createroom
700701 ratelimit: set to False to disable the rate limiter
701702
702703 creator_join_profile:
@@ -707,14 +708,17 @@ async def create_room(
707708 `avatar_url` and/or `displayname`.
708709
709710 Returns:
710- First, a dict containing the keys `room_id` and, if an alias
711- was, requested, `room_alias`. Secondly, the stream_id of the
712- last persisted event.
711+ A 3-tuple containing:
712+ - the room ID;
713+ - if requested, the room alias, otherwise None; and
714+ - the `stream_id` of the last persisted event.
713715 Raises:
714- SynapseError if the room ID couldn't be stored, 3pid invitation config
715- validation failed, or something went horribly wrong.
716- ResourceLimitError if server is blocked to some resource being
717- exceeded
716+ SynapseError:
717+ if the room ID couldn't be stored, 3pid invitation config
718+ validation failed, or something went horribly wrong.
719+ ResourceLimitError:
720+ if server is blocked to some resource being
721+ exceeded
718722 """
719723 user_id = requester .user .to_string ()
720724
@@ -1024,19 +1028,14 @@ async def create_room(
10241028 last_sent_event_id = member_event_id
10251029 depth += 1
10261030
1027- result = {"room_id" : room_id }
1028-
1029- if room_alias :
1030- result ["room_alias" ] = room_alias .to_string ()
1031-
10321031 # Always wait for room creation to propagate before returning
10331032 await self ._replication .wait_for_stream_position (
10341033 self .hs .config .worker .events_shard_config .get_instance (room_id ),
10351034 "events" ,
10361035 last_stream_id ,
10371036 )
10381037
1039- return result , last_stream_id
1038+ return room_id , room_alias , last_stream_id
10401039
10411040 async def _send_events_for_new_room (
10421041 self ,
@@ -1825,7 +1824,7 @@ async def shutdown_room(
18251824 new_room_user_id , authenticated_entity = requester_user_id
18261825 )
18271826
1828- info , stream_id = await self ._room_creation_handler .create_room (
1827+ new_room_id , _ , stream_id = await self ._room_creation_handler .create_room (
18291828 room_creator_requester ,
18301829 config = {
18311830 "preset" : RoomCreationPreset .PUBLIC_CHAT ,
@@ -1834,7 +1833,6 @@ async def shutdown_room(
18341833 },
18351834 ratelimit = False ,
18361835 )
1837- new_room_id = info ["room_id" ]
18381836
18391837 logger .info (
18401838 "Shutting down room %r, joining to new room: %r" , room_id , new_room_id
@@ -1887,6 +1885,7 @@ async def shutdown_room(
18871885
18881886 # Join users to new room
18891887 if new_room_user_id :
1888+ assert new_room_id is not None
18901889 await self .room_member_handler .update_membership (
18911890 requester = target_requester ,
18921891 target = target_requester .user ,
@@ -1919,6 +1918,7 @@ async def shutdown_room(
19191918
19201919 aliases_for_room = await self .store .get_aliases_for_room (room_id )
19211920
1921+ assert new_room_id is not None
19221922 await self .store .update_aliases_for_room (
19231923 room_id , new_room_id , requester_user_id
19241924 )
0 commit comments