From 4788d4ec17ee723c78f779de727a64a54273fc9a Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 9 May 2022 10:20:49 +0100 Subject: [PATCH 1/3] Don't error on unknown receipt types Fixes #12669 --- synapse/rest/client/read_marker.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/synapse/rest/client/read_marker.py b/synapse/rest/client/read_marker.py index 1583e903cd88..b18b19dde149 100644 --- a/synapse/rest/client/read_marker.py +++ b/synapse/rest/client/read_marker.py @@ -50,17 +50,21 @@ async def on_POST( body = parse_json_object_from_request(request) - valid_receipt_types = {ReceiptTypes.READ, ReceiptTypes.FULLY_READ} - if self.config.experimental.msc2285_enabled: - valid_receipt_types.add(ReceiptTypes.READ_PRIVATE) - - if set(body.keys()) > valid_receipt_types: - raise SynapseError( - 400, - "Receipt type must be 'm.read', 'org.matrix.msc2285.read.private' or 'm.fully_read'" - if self.config.experimental.msc2285_enabled - else "Receipt type must be 'm.read' or 'm.fully_read'", - ) + valid_receipt_types = { + ReceiptTypes.READ, + ReceiptTypes.FULLY_READ, + ReceiptTypes.READ_PRIVATE, + } + + unrecognized_types = set(body.keys()) - valid_receipt_types + if unrecognized_types: + # It's fine if there are unrecognized receipt types, but let's log + # it to help debug clients that have typoed the receipt type. + # + # We specifically *don't* error here, as a) it stops us processing + # the valid receipts, and b) we need to be extensible on receipt + # types. + logger.info("Ignoring unrecognized receipt types: %s", unrecognized_types) read_event_id = body.get(ReceiptTypes.READ, None) if read_event_id: From e05da07625045ca7133d8540325c57119e4d31ed Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 9 May 2022 10:21:53 +0100 Subject: [PATCH 2/3] Newsfile --- changelog.d/12670.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/12670.feature diff --git a/changelog.d/12670.feature b/changelog.d/12670.feature new file mode 100644 index 000000000000..cd5c45029ee1 --- /dev/null +++ b/changelog.d/12670.feature @@ -0,0 +1 @@ +Implement [changes](https://github.com/matrix-org/matrix-spec-proposals/pull/2285/commits/4a77139249c2e830aec3c7d6bd5501a514d1cc27) to [MSC2285 (hidden read receipts)](https://github.com/matrix-org/matrix-spec-proposals/pull/2285). Contributed by @SimonBrandner. From be6bc36ca297cdad13b2ce5b39d8d3ac5756119d Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 9 May 2022 10:32:21 +0100 Subject: [PATCH 3/3] Lint --- synapse/rest/client/read_marker.py | 1 - 1 file changed, 1 deletion(-) diff --git a/synapse/rest/client/read_marker.py b/synapse/rest/client/read_marker.py index b18b19dde149..3644705e6abb 100644 --- a/synapse/rest/client/read_marker.py +++ b/synapse/rest/client/read_marker.py @@ -16,7 +16,6 @@ from typing import TYPE_CHECKING, Tuple from synapse.api.constants import ReceiptTypes -from synapse.api.errors import SynapseError from synapse.http.server import HttpServer from synapse.http.servlet import RestServlet, parse_json_object_from_request from synapse.http.site import SynapseRequest