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

Commit c5969b3

Browse files
authored
Don't error on unknown receipt types (#12670)
Fixes #12669
1 parent 77258b6 commit c5969b3

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

changelog.d/12670.feature

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.

synapse/rest/client/read_marker.py

+15-12
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from typing import TYPE_CHECKING, Tuple
1717

1818
from synapse.api.constants import ReceiptTypes
19-
from synapse.api.errors import SynapseError
2019
from synapse.http.server import HttpServer
2120
from synapse.http.servlet import RestServlet, parse_json_object_from_request
2221
from synapse.http.site import SynapseRequest
@@ -50,17 +49,21 @@ async def on_POST(
5049

5150
body = parse_json_object_from_request(request)
5251

53-
valid_receipt_types = {ReceiptTypes.READ, ReceiptTypes.FULLY_READ}
54-
if self.config.experimental.msc2285_enabled:
55-
valid_receipt_types.add(ReceiptTypes.READ_PRIVATE)
56-
57-
if set(body.keys()) > valid_receipt_types:
58-
raise SynapseError(
59-
400,
60-
"Receipt type must be 'm.read', 'org.matrix.msc2285.read.private' or 'm.fully_read'"
61-
if self.config.experimental.msc2285_enabled
62-
else "Receipt type must be 'm.read' or 'm.fully_read'",
63-
)
52+
valid_receipt_types = {
53+
ReceiptTypes.READ,
54+
ReceiptTypes.FULLY_READ,
55+
ReceiptTypes.READ_PRIVATE,
56+
}
57+
58+
unrecognized_types = set(body.keys()) - valid_receipt_types
59+
if unrecognized_types:
60+
# It's fine if there are unrecognized receipt types, but let's log
61+
# it to help debug clients that have typoed the receipt type.
62+
#
63+
# We specifically *don't* error here, as a) it stops us processing
64+
# the valid receipts, and b) we need to be extensible on receipt
65+
# types.
66+
logger.info("Ignoring unrecognized receipt types: %s", unrecognized_types)
6467

6568
read_event_id = body.get(ReceiptTypes.READ, None)
6669
if read_event_id:

0 commit comments

Comments
 (0)