From 7eeef7d33332b2ab094bee8f9a66a926b81e60dd Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 25 Aug 2023 10:19:31 -0400 Subject: [PATCH 1/5] Send proper JSON POST data. --- synapse/federation/transport/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/federation/transport/client.py b/synapse/federation/transport/client.py index 0b17f713ea94..d8d2a4516339 100644 --- a/synapse/federation/transport/client.py +++ b/synapse/federation/transport/client.py @@ -480,7 +480,7 @@ async def get_public_rooms( path = _create_v1_path("/publicRooms") data: Dict[str, Any] = { - "include_all_networks": "true" if include_all_networks else "false" + "include_all_networks": include_all_networks } if third_party_instance_id: data["third_party_instance_id"] = third_party_instance_id From 6da9c1769cfbb79e6f018733a642c3f0893a0e8d Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 25 Aug 2023 10:19:38 -0400 Subject: [PATCH 2/5] Avoid unneeded lists. --- synapse/federation/transport/client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/synapse/federation/transport/client.py b/synapse/federation/transport/client.py index d8d2a4516339..d3d5e97bcf72 100644 --- a/synapse/federation/transport/client.py +++ b/synapse/federation/transport/client.py @@ -511,11 +511,11 @@ async def get_public_rooms( "include_all_networks": "true" if include_all_networks else "false" } if third_party_instance_id: - args["third_party_instance_id"] = (third_party_instance_id,) + args["third_party_instance_id"] = third_party_instance_id if limit: - args["limit"] = [str(limit)] + args["limit"] = str(limit) if since_token: - args["since"] = [since_token] + args["since"] = since_token try: response = await self.client.get_json( From 5bde5cf2f83a73b9fdda7e7c59a1ce3d21352058 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 25 Aug 2023 10:20:02 -0400 Subject: [PATCH 3/5] Path is always the same. --- synapse/federation/transport/client.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/synapse/federation/transport/client.py b/synapse/federation/transport/client.py index d3d5e97bcf72..835a1d5f8091 100644 --- a/synapse/federation/transport/client.py +++ b/synapse/federation/transport/client.py @@ -475,10 +475,10 @@ async def get_public_rooms( See synapse.federation.federation_client.FederationClient.get_public_rooms for more information. """ + path = _create_v1_path("/publicRooms") + if search_filter: # this uses MSC2197 (Search Filtering over Federation) - path = _create_v1_path("/publicRooms") - data: Dict[str, Any] = { "include_all_networks": include_all_networks } @@ -505,8 +505,6 @@ async def get_public_rooms( ) raise else: - path = _create_v1_path("/publicRooms") - args: Dict[str, Union[str, Iterable[str]]] = { "include_all_networks": "true" if include_all_networks else "false" } From 9fb65a1aa0fe43c8a8bdd914c606ec1be5d2685e Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 25 Aug 2023 10:41:12 -0400 Subject: [PATCH 4/5] Newsfragment --- changelog.d/16185.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/16185.bugfix diff --git a/changelog.d/16185.bugfix b/changelog.d/16185.bugfix new file mode 100644 index 000000000000..e62c9c7a0d8b --- /dev/null +++ b/changelog.d/16185.bugfix @@ -0,0 +1 @@ +Fix a spec compliance issue where requests to the `/publicRooms` federation API would specify `include_all_networks` as a string. From 1ded0d2040478b2b4b7d1d6cddb0d029c4a22bc3 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 25 Aug 2023 10:43:25 -0400 Subject: [PATCH 5/5] Lint --- synapse/federation/transport/client.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/synapse/federation/transport/client.py b/synapse/federation/transport/client.py index 835a1d5f8091..5ce3f345cbeb 100644 --- a/synapse/federation/transport/client.py +++ b/synapse/federation/transport/client.py @@ -479,9 +479,7 @@ async def get_public_rooms( if search_filter: # this uses MSC2197 (Search Filtering over Federation) - data: Dict[str, Any] = { - "include_all_networks": include_all_networks - } + data: Dict[str, Any] = {"include_all_networks": include_all_networks} if third_party_instance_id: data["third_party_instance_id"] = third_party_instance_id if limit: