|
16 | 16 | from typing import TYPE_CHECKING, Tuple
|
17 | 17 |
|
18 | 18 | from synapse.api.constants import ReceiptTypes
|
19 |
| -from synapse.api.errors import SynapseError |
20 | 19 | from synapse.http.server import HttpServer
|
21 | 20 | from synapse.http.servlet import RestServlet, parse_json_object_from_request
|
22 | 21 | from synapse.http.site import SynapseRequest
|
@@ -50,17 +49,21 @@ async def on_POST(
|
50 | 49 |
|
51 | 50 | body = parse_json_object_from_request(request)
|
52 | 51 |
|
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) |
64 | 67 |
|
65 | 68 | read_event_id = body.get(ReceiptTypes.READ, None)
|
66 | 69 | if read_event_id:
|
|
0 commit comments