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

Commit 85a7a20

Browse files
David Robertsonsquahtx
David Robertson
andauthored
Also use stable name in SendJoinResponse struct (#14841)
* Also use stable name in SendJoinResponse struct follow-up to #14832 * Changelog * Fix a rename I missed * Run black * Update synapse/federation/federation_client.py Co-authored-by: Sean Quah <[email protected]> Co-authored-by: Sean Quah <[email protected]>
1 parent 5f171c1 commit 85a7a20

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

changelog.d/14841.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Faster joins: use stable identifiers from [MSC3706](https://github.com/matrix-org/matrix-spec-proposals/pull/3706).

synapse/federation/federation_client.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1142,17 +1142,17 @@ async def _execute(pdu: EventBase) -> None:
11421142
% (auth_chain_create_events,)
11431143
)
11441144

1145-
if response.partial_state and not response.servers_in_room:
1145+
if response.members_omitted and not response.servers_in_room:
11461146
raise InvalidResponseError(
1147-
"partial_state was set, but no servers were listed in the room"
1147+
"members_omitted was set, but no servers were listed in the room"
11481148
)
11491149

11501150
return SendJoinResult(
11511151
event=event,
11521152
state=signed_state,
11531153
auth_chain=signed_auth,
11541154
origin=destination,
1155-
partial_state=response.partial_state,
1155+
partial_state=response.members_omitted,
11561156
servers_in_room=response.servers_in_room or [],
11571157
)
11581158

synapse/federation/federation_server.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1502,7 +1502,7 @@ def _get_event_ids_for_partial_state_join(
15021502
prev_state_ids: StateMap[str],
15031503
summary: Dict[str, MemberSummary],
15041504
) -> Collection[str]:
1505-
"""Calculate state to be retuned in a partial_state send_join
1505+
"""Calculate state to be returned in a partial_state send_join
15061506
15071507
Args:
15081508
join_event: the join event being send_joined

synapse/federation/transport/client.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ class SendJoinResponse:
795795
event: Optional[EventBase] = None
796796

797797
# The room state is incomplete
798-
partial_state: bool = False
798+
members_omitted: bool = False
799799

800800
# List of servers in the room
801801
servers_in_room: Optional[List[str]] = None
@@ -835,16 +835,18 @@ def _event_list_parser(
835835

836836

837837
@ijson.coroutine
838-
def _partial_state_parser(response: SendJoinResponse) -> Generator[None, Any, None]:
838+
def _members_omitted_parser(response: SendJoinResponse) -> Generator[None, Any, None]:
839839
"""Helper function for use with `ijson.items_coro`
840840
841-
Parses the partial_state field in send_join responses
841+
Parses the members_omitted field in send_join responses
842842
"""
843843
while True:
844844
val = yield
845845
if not isinstance(val, bool):
846-
raise TypeError("partial_state must be a boolean")
847-
response.partial_state = val
846+
raise TypeError(
847+
"members_omitted (formerly org.matrix.msc370c.partial_state) must be a boolean"
848+
)
849+
response.members_omitted = val
848850

849851

850852
@ijson.coroutine
@@ -905,15 +907,15 @@ def __init__(self, room_version: RoomVersion, v1_api: bool):
905907
if not v1_api:
906908
self._coros.append(
907909
ijson.items_coro(
908-
_partial_state_parser(self._response),
910+
_members_omitted_parser(self._response),
909911
"org.matrix.msc3706.partial_state",
910912
use_float="True",
911913
)
912914
)
913915
# The stable field name comes last, so it "wins" if the fields disagree
914916
self._coros.append(
915917
ijson.items_coro(
916-
_partial_state_parser(self._response),
918+
_members_omitted_parser(self._response),
917919
"members_omitted",
918920
use_float="True",
919921
)

tests/federation/transport/test_client.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ def test_two_writes(self) -> None:
6868
self.assertEqual(len(parsed_response.state), 1, parsed_response)
6969
self.assertEqual(parsed_response.event_dict, {}, parsed_response)
7070
self.assertIsNone(parsed_response.event, parsed_response)
71-
self.assertFalse(parsed_response.partial_state, parsed_response)
71+
self.assertFalse(parsed_response.members_omitted, parsed_response)
7272
self.assertEqual(parsed_response.servers_in_room, None, parsed_response)
7373

7474
def test_partial_state(self) -> None:
75-
"""Check that the partial_state flag is correctly parsed"""
75+
"""Check that the members_omitted flag is correctly parsed"""
7676

7777
def parse(response: JsonDict) -> bool:
7878
parser = SendJoinParser(RoomVersions.V1, False)
@@ -83,7 +83,7 @@ def parse(response: JsonDict) -> bool:
8383

8484
# Retrieve and check the parsed SendJoinResponse
8585
parsed_response = parser.finish()
86-
return parsed_response.partial_state
86+
return parsed_response.members_omitted
8787

8888
self.assertTrue(parse({"members_omitted": True}))
8989
self.assertTrue(parse({"org.matrix.msc3706.partial_state": True}))

0 commit comments

Comments
 (0)