From d42cedbb18116af2acebcd1ee429709f280423fe Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Wed, 3 May 2023 13:52:38 +0300 Subject: [PATCH 1/3] Stabilize MSC2659 support Signed-off-by: Tulir Asokan --- changelog.d/15528.feature | 1 + synapse/appservice/api.py | 2 +- synapse/config/experimental.py | 3 --- synapse/rest/client/appservice_ping.py | 10 ++++------ synapse/rest/client/versions.py | 2 +- 5 files changed, 7 insertions(+), 11 deletions(-) create mode 100644 changelog.d/15528.feature diff --git a/changelog.d/15528.feature b/changelog.d/15528.feature new file mode 100644 index 000000000000..6a0cb32cf195 --- /dev/null +++ b/changelog.d/15528.feature @@ -0,0 +1 @@ +Stabilized support for [MSC2659](https://github.com/matrix-org/matrix-spec-proposals/pull/2659): application service ping endpoint. Contributed by Tulir @ Beeper. diff --git a/synapse/appservice/api.py b/synapse/appservice/api.py index 024098e9cbb0..5fb3d5083da2 100644 --- a/synapse/appservice/api.py +++ b/synapse/appservice/api.py @@ -326,7 +326,7 @@ async def ping(self, service: "ApplicationService", txn_id: Optional[str]) -> No assert service.hs_token is not None await self.post_json_get_json( - uri=f"{service.url}{APP_SERVICE_UNSTABLE_PREFIX}/fi.mau.msc2659/ping", + uri=f"{service.url}{APP_SERVICE_PREFIX}/ping", post_json={"transaction_id": txn_id}, headers={"Authorization": [f"Bearer {service.hs_token}"]}, ) diff --git a/synapse/config/experimental.py b/synapse/config/experimental.py index cab7ccf4b768..e8548367da9a 100644 --- a/synapse/config/experimental.py +++ b/synapse/config/experimental.py @@ -189,9 +189,6 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None: # MSC3967: Do not require UIA when first uploading cross signing keys self.msc3967_enabled = experimental.get("msc3967_enabled", False) - # MSC2659: Application service ping endpoint - self.msc2659_enabled = experimental.get("msc2659_enabled", False) - # MSC3981: Recurse relations self.msc3981_recurse_relations = experimental.get( "msc3981_recurse_relations", False diff --git a/synapse/rest/client/appservice_ping.py b/synapse/rest/client/appservice_ping.py index 31466a4ad4cb..3f553d14d187 100644 --- a/synapse/rest/client/appservice_ping.py +++ b/synapse/rest/client/appservice_ping.py @@ -39,9 +39,8 @@ class AppservicePingRestServlet(RestServlet): PATTERNS = client_patterns( - "/fi.mau.msc2659/appservice/(?P[^/]*)/ping", - unstable=True, - releases=(), + "/appservice/(?P[^/]*)/ping", + releases=("v1",), ) def __init__(self, hs: "HomeServer"): @@ -107,9 +106,8 @@ async def on_POST( duration = time.monotonic() - start - return HTTPStatus.OK, {"duration": int(duration * 1000)} + return HTTPStatus.OK, {"duration_ms": int(duration * 1000)} def register_servlets(hs: "HomeServer", http_server: HttpServer) -> None: - if hs.config.experimental.msc2659_enabled: - AppservicePingRestServlet(hs).register(http_server) + AppservicePingRestServlet(hs).register(http_server) diff --git a/synapse/rest/client/versions.py b/synapse/rest/client/versions.py index 59aed66464e5..5c98916ec2bc 100644 --- a/synapse/rest/client/versions.py +++ b/synapse/rest/client/versions.py @@ -111,7 +111,7 @@ def on_GET(self, request: Request) -> Tuple[int, JsonDict]: # Allows moderators to fetch redacted event content as described in MSC2815 "fi.mau.msc2815": self.config.experimental.msc2815_enabled, # Adds a ping endpoint for appservices to check HS->AS connection - "fi.mau.msc2659": self.config.experimental.msc2659_enabled, + "fi.mau.msc2659.stable": True, # TODO: remove when "v1.7" is added above # Adds support for login token requests as per MSC3882 "org.matrix.msc3882": self.config.experimental.msc3882_enabled, # Adds support for remotely enabling/disabling pushers, as per MSC3881 From f061b27c1d4781dbe4ad730ca822092a05f30e42 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 5 May 2023 14:45:51 +0300 Subject: [PATCH 2/3] Update error codes too Signed-off-by: Tulir Asokan --- synapse/api/errors.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/synapse/api/errors.py b/synapse/api/errors.py index f2d6f9ab2d9e..8c7c94b04568 100644 --- a/synapse/api/errors.py +++ b/synapse/api/errors.py @@ -108,10 +108,10 @@ class Codes(str, Enum): USER_AWAITING_APPROVAL = "ORG.MATRIX.MSC3866_USER_AWAITING_APPROVAL" - AS_PING_URL_NOT_SET = "FI.MAU.MSC2659_URL_NOT_SET" - AS_PING_BAD_STATUS = "FI.MAU.MSC2659_BAD_STATUS" - AS_PING_CONNECTION_TIMEOUT = "FI.MAU.MSC2659_CONNECTION_TIMEOUT" - AS_PING_CONNECTION_FAILED = "FI.MAU.MSC2659_CONNECTION_FAILED" + AS_PING_URL_NOT_SET = "M_URL_NOT_SET" + AS_PING_BAD_STATUS = "M_BAD_STATUS" + AS_PING_CONNECTION_TIMEOUT = "M_CONNECTION_TIMEOUT" + AS_PING_CONNECTION_FAILED = "M_CONNECTION_FAILED" # Attempt to send a second annotation with the same event type & annotation key # MSC2677 From dbc290caf03e16fd6579a51d7f71e43b2ecd8515 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Tue, 9 May 2023 14:19:29 -0400 Subject: [PATCH 3/3] Update changelog. --- changelog.d/15528.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/15528.feature b/changelog.d/15528.feature index 6a0cb32cf195..aae9fa1ecf34 100644 --- a/changelog.d/15528.feature +++ b/changelog.d/15528.feature @@ -1 +1 @@ -Stabilized support for [MSC2659](https://github.com/matrix-org/matrix-spec-proposals/pull/2659): application service ping endpoint. Contributed by Tulir @ Beeper. +Stabilize support for [MSC2659](https://github.com/matrix-org/matrix-spec-proposals/pull/2659): application service ping endpoint. Contributed by Tulir @ Beeper.