From 61ed3a48fc38f46b878ce37559d430e22ada830d Mon Sep 17 00:00:00 2001 From: Dirk Klimpel <5740567+dklimpel@users.noreply.github.com> Date: Sun, 26 Mar 2023 17:31:08 +0200 Subject: [PATCH 1/4] Enable `directory` --- synapse/rest/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/synapse/rest/__init__.py b/synapse/rest/__init__.py index 55b448adfdba..547d6775c3d9 100644 --- a/synapse/rest/__init__.py +++ b/synapse/rest/__init__.py @@ -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) voip.register_servlets(hs, client_resource) if is_main_process: pusher.register_servlets(hs, client_resource) From 1c6885abe2073e75b83e6df88ba082b607c67abb Mon Sep 17 00:00:00 2001 From: dklimpel <5740567+dklimpel@users.noreply.github.com> Date: Sun, 26 Mar 2023 17:59:25 +0200 Subject: [PATCH 2/4] move to worker store --- docker/configure_workers_and_start.py | 1 + docs/workers.md | 1 + synapse/rest/client/directory.py | 1 + synapse/storage/databases/main/directory.py | 6 ++++-- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docker/configure_workers_and_start.py b/docker/configure_workers_and_start.py index 3f2f5c2daf85..d9211158fa75 100755 --- a/docker/configure_workers_and_start.py +++ b/docker/configure_workers_and_start.py @@ -172,6 +172,7 @@ "^/_matrix/client/v1/rooms/.*/timestamp_to_event$", "^/_matrix/client/(api/v1|r0|v3|unstable)/search", "^/_matrix/client/(r0|v3|unstable)/user/.*/filter(/|$)", + "^/_matrix/client/(api/v1|r0|v3|unstable)/directory/room/.*$", ], "shared_extra_conf": {}, "worker_extra_conf": "", diff --git a/docs/workers.md b/docs/workers.md index bf7690f5aff2..bfa53d370750 100644 --- a/docs/workers.md +++ b/docs/workers.md @@ -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$ diff --git a/synapse/rest/client/directory.py b/synapse/rest/client/directory.py index f17b4c8d2229..9bff411fee78 100644 --- a/synapse/rest/client/directory.py +++ b/synapse/rest/client/directory.py @@ -45,6 +45,7 @@ def register_servlets(hs: "HomeServer", http_server: HttpServer) -> None: class ClientDirectoryServer(RestServlet): PATTERNS = client_patterns("/directory/room/(?P[^/]*)$", v1=True) + CATEGORY = "Client API requests" def __init__(self, hs: "HomeServer"): super().__init__() diff --git a/synapse/storage/databases/main/directory.py b/synapse/storage/databases/main/directory.py index 44aa181174ac..3cb4c9072907 100644 --- a/synapse/storage/databases/main/directory.py +++ b/synapse/storage/databases/main/directory.py @@ -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 @@ -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 From 4e9c91213bd46f55531055ab2ea17fe9e6e22c88 Mon Sep 17 00:00:00 2001 From: dklimpel <5740567+dklimpel@users.noreply.github.com> Date: Mon, 27 Mar 2023 21:37:53 +0200 Subject: [PATCH 3/4] newsfile --- changelog.d/15333.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/15333.feature diff --git a/changelog.d/15333.feature b/changelog.d/15333.feature new file mode 100644 index 000000000000..35ea89ad8982 --- /dev/null +++ b/changelog.d/15333.feature @@ -0,0 +1 @@ +Allow loading `/directory/room/{roomAlias}` endpoint on workers. \ No newline at end of file From 82796c0a581df291777d007f7cf07e33d6a1deae Mon Sep 17 00:00:00 2001 From: dklimpel <5740567+dklimpel@users.noreply.github.com> Date: Thu, 30 Mar 2023 12:21:40 +0200 Subject: [PATCH 4/4] disable `ClientDirectoryListServer` and `ClientAppserviceDirectoryListServer` for workers --- synapse/rest/client/directory.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/synapse/rest/client/directory.py b/synapse/rest/client/directory.py index 9bff411fee78..570bb52747ab 100644 --- a/synapse/rest/client/directory.py +++ b/synapse/rest/client/directory.py @@ -39,8 +39,9 @@ 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):