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

Load /directory/room/{roomAlias} endpoint on workers #15333

Merged
merged 5 commits into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions changelog.d/15333.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow loading `/directory/room/{roomAlias}` endpoint on workers.
1 change: 1 addition & 0 deletions docker/configure_workers_and_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
"^/_matrix/client/(api/v1|r0|v3|unstable)/search",
"^/_matrix/client/(r0|v3|unstable)/user/.*/filter(/|$)",
"^/_matrix/client/(r0|v3|unstable)/password_policy$",
"^/_matrix/client/(api/v1|r0|v3|unstable)/directory/room/.*$",
],
"shared_extra_conf": {},
"worker_extra_conf": "",
Expand Down
1 change: 1 addition & 0 deletions docs/workers.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ information.
^/_matrix/client/(api/v1|r0|v3|unstable/.*)/rooms/.*/aliases
^/_matrix/client/(api/v1|r0|v3|unstable)/search$
^/_matrix/client/(r0|v3|unstable)/user/.*/filter(/|$)
^/_matrix/client/(api/v1|r0|v3|unstable)/directory/room/.*$

# Encryption requests
^/_matrix/client/(r0|v3|unstable)/keys/query$
Expand Down
3 changes: 1 addition & 2 deletions synapse/rest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ def register_servlets(client_resource: HttpServer, hs: "HomeServer") -> None:
login.register_servlets(hs, client_resource)
profile.register_servlets(hs, client_resource)
presence.register_servlets(hs, client_resource)
if is_main_process:
directory.register_servlets(hs, client_resource)
directory.register_servlets(hs, client_resource)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is also loading ClientAppserviceDirectoryListServer and ClientDirectoryListServer on the workers.

At a skim, it looks fine, but it should then have a CATEGORY and it should be in the path map like the other endpoints?
If you don't have time to check that they're fine on workers, I'd add if is_main_process inside directory.register_servlets and leave those until later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is also loading ClientAppserviceDirectoryListServer and ClientDirectoryListServer on the workers.

I have it disabled.

voip.register_servlets(hs, client_resource)
if is_main_process:
pusher.register_servlets(hs, client_resource)
Expand Down
6 changes: 4 additions & 2 deletions synapse/rest/client/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@

def register_servlets(hs: "HomeServer", http_server: HttpServer) -> None:
ClientDirectoryServer(hs).register(http_server)
ClientDirectoryListServer(hs).register(http_server)
ClientAppserviceDirectoryListServer(hs).register(http_server)
if hs.config.worker.worker_app is None:
ClientDirectoryListServer(hs).register(http_server)
ClientAppserviceDirectoryListServer(hs).register(http_server)


class ClientDirectoryServer(RestServlet):
PATTERNS = client_patterns("/directory/room/(?P<room_alias>[^/]*)$", v1=True)
CATEGORY = "Client API requests"

def __init__(self, hs: "HomeServer"):
super().__init__()
Expand Down
6 changes: 4 additions & 2 deletions synapse/storage/databases/main/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ def alias_txn(txn: LoggingTransaction) -> None:
409, "Room alias %s already exists" % room_alias.to_string()
)


class DirectoryStore(DirectoryWorkerStore):
async def delete_room_alias(self, room_alias: RoomAlias) -> Optional[str]:
room_id = await self.db_pool.runInteraction(
"delete_room_alias", self._delete_room_alias_txn, room_alias
Expand Down Expand Up @@ -201,3 +199,7 @@ def _update_aliases_for_room_txn(txn: LoggingTransaction) -> None:
await self.db_pool.runInteraction(
"_update_aliases_for_room_txn", _update_aliases_for_room_txn
)


class DirectoryStore(DirectoryWorkerStore):
pass