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

Remove unstable APIs for /hierarchy. #12851

Merged
merged 5 commits into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/12851.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove the unstable `/hierarchy` endpoint from [MSC2946](https://github.com/matrix-org/matrix-doc/pull/2946).
4 changes: 2 additions & 2 deletions docs/workers.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ information.
^/_matrix/federation/v1/user/devices/
^/_matrix/federation/v1/get_groups_publicised$
^/_matrix/key/v2/query
^/_matrix/federation/(v1|unstable/org.matrix.msc2946)/hierarchy/
^/_matrix/federation/v1/hierarchy/

# Inbound federation transaction request
^/_matrix/federation/v1/send/
Expand All @@ -205,7 +205,7 @@ information.
^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/context/.*$
^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/members$
^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/state$
^/_matrix/client/(v1|unstable/org.matrix.msc2946)/rooms/.*/hierarchy$
^/_matrix/client/v1/rooms/.*/hierarchy$
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be v3? Surely its not v1?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a new endpoint, so it was added as v1. The only endpoints that became v3 were the ones which existed as r0.

See

PATTERNS = (
re.compile(
"^/_matrix/client/(v1|unstable/org.matrix.msc2946)"
"/rooms/(?P<room_id>[^/]*)/hierarchy$"
),
)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I forgot that that was how we decided to do it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to confuse a lot of people. 😄

^/_matrix/client/unstable/im.nheko.summary/rooms/.*/summary$
^/_matrix/client/(r0|v3|unstable)/account/3pid$
^/_matrix/client/(r0|v3|unstable)/devices$
Expand Down
5 changes: 0 additions & 5 deletions synapse/federation/transport/server/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,10 +650,6 @@ async def on_GET(
)


class FederationRoomHierarchyUnstableServlet(FederationRoomHierarchyServlet):
PREFIX = FEDERATION_UNSTABLE_PREFIX + "/org.matrix.msc2946"


class RoomComplexityServlet(BaseFederationServlet):
"""
Indicates to other servers how complex (and therefore likely
Expand Down Expand Up @@ -752,7 +748,6 @@ async def on_POST(
FederationVersionServlet,
RoomComplexityServlet,
FederationRoomHierarchyServlet,
FederationRoomHierarchyUnstableServlet,
FederationV1SendKnockServlet,
FederationMakeKnockServlet,
FederationAccountStatusServlet,
Expand Down
5 changes: 1 addition & 4 deletions synapse/handlers/room_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ async def _is_remote_room_accessible(
# The API doesn't return the room version so assume that a
# join rule of knock is valid.
if (
room.get("join_rules") in (JoinRules.PUBLIC, JoinRules.KNOCK)
room.get("join_rule") in (JoinRules.PUBLIC, JoinRules.KNOCK)
or room.get("world_readable") is True
):
return True
Expand Down Expand Up @@ -713,9 +713,6 @@ async def _build_room_entry(self, room_id: str, for_federation: bool) -> JsonDic
"canonical_alias": stats["canonical_alias"],
"num_joined_members": stats["joined_members"],
"avatar_url": stats["avatar"],
# plural join_rules is a documentation error but kept for historical
# purposes. Should match /publicRooms.
"join_rules": stats["join_rules"],
"join_rule": stats["join_rules"],
"world_readable": (
stats["history_visibility"] == HistoryVisibility.WORLD_READABLE
Expand Down
7 changes: 1 addition & 6 deletions synapse/rest/client/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -1193,12 +1193,7 @@ async def on_GET(


class RoomHierarchyRestServlet(RestServlet):
PATTERNS = (
re.compile(
"^/_matrix/client/(v1|unstable/org.matrix.msc2946)"
"/rooms/(?P<room_id>[^/]*)/hierarchy$"
),
)
PATTERNS = (re.compile("^/_matrix/client/v1/rooms/(?P<room_id>[^/]*)/hierarchy$"),)

def __init__(self, hs: "HomeServer"):
super().__init__()
Expand Down
20 changes: 10 additions & 10 deletions tests/handlers/test_room_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def _assert_hierarchy(
result_children_ids.append(
[
(cs["room_id"], cs["state_key"])
for cs in result_room.get("children_state")
for cs in result_room["children_state"]
]
)

Expand Down Expand Up @@ -772,39 +772,39 @@ def test_fed_filtering(self):
{
"room_id": public_room,
"world_readable": False,
"join_rules": JoinRules.PUBLIC,
"join_rule": JoinRules.PUBLIC,
},
),
(
knock_room,
{
"room_id": knock_room,
"world_readable": False,
"join_rules": JoinRules.KNOCK,
"join_rule": JoinRules.KNOCK,
},
),
(
not_invited_room,
{
"room_id": not_invited_room,
"world_readable": False,
"join_rules": JoinRules.INVITE,
"join_rule": JoinRules.INVITE,
},
),
(
invited_room,
{
"room_id": invited_room,
"world_readable": False,
"join_rules": JoinRules.INVITE,
"join_rule": JoinRules.INVITE,
},
),
(
restricted_room,
{
"room_id": restricted_room,
"world_readable": False,
"join_rules": JoinRules.RESTRICTED,
"join_rule": JoinRules.RESTRICTED,
"allowed_room_ids": [],
},
),
Expand All @@ -813,7 +813,7 @@ def test_fed_filtering(self):
{
"room_id": restricted_accessible_room,
"world_readable": False,
"join_rules": JoinRules.RESTRICTED,
"join_rule": JoinRules.RESTRICTED,
"allowed_room_ids": [self.room],
},
),
Expand All @@ -822,15 +822,15 @@ def test_fed_filtering(self):
{
"room_id": world_readable_room,
"world_readable": True,
"join_rules": JoinRules.INVITE,
"join_rule": JoinRules.INVITE,
},
),
(
joined_room,
{
"room_id": joined_room,
"world_readable": False,
"join_rules": JoinRules.INVITE,
"join_rule": JoinRules.INVITE,
},
),
)
Expand Down Expand Up @@ -911,7 +911,7 @@ def test_fed_invited(self):
{
"room_id": fed_room,
"world_readable": False,
"join_rules": JoinRules.INVITE,
"join_rule": JoinRules.INVITE,
},
)

Expand Down