Skip to content
Open
Changes from all 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
11 changes: 1 addition & 10 deletions synapse/handlers/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,16 +323,7 @@ async def on_directory_query(self, args: JsonDict) -> JsonDict:
if not self.hs.is_mine(room_alias):
raise SynapseError(400, "Room Alias is not hosted on this homeserver")

result = await self.get_association_from_room_alias(room_alias)

if result is not None:
return {"room_id": result.room_id, "servers": result.servers}
else:
raise SynapseError(
404,
"Room alias %r not found" % (room_alias.to_string(),),
Codes.NOT_FOUND,
)
return await self.get_association(room_alias)
Copy link
Contributor

Choose a reason for hiding this comment

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

Afraid I'm not following how this improves anything, is there any chance you can sketch an example?

To put my confusion into words:

get_association appears to just call get_association_from_room_alias if the alias is managed by this server anyway.
And if the alias is not owned by this server, we make a federation request to the server that does.

But why would someone be sending us an SS API query for an alias that we don't own?

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for the timely response 🙏🏻. To clarify, our high-level goal here is only to populate the response with extra servers. There is no intent to change the resolution process or answer queries on behalf of other servers.

I sympathize with your confusion as I just revisited get_association() myself just now. The branch entered if the alias is owned by the server to call get_association_from_room_alias() does not return early. This allows extra_servers to be populated further down in get_association() and that's what will achieve the goal here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Aha, yup, not sure how I didn't see that. Yeah this looks sensible to me


async def _update_canonical_alias(
self, requester: Requester, user_id: str, room_id: str, room_alias: RoomAlias
Expand Down
Loading