mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2025-01-16 16:47:10 -05:00
parent
77258b6725
commit
c5969b346d
1
changelog.d/12670.feature
Normal file
1
changelog.d/12670.feature
Normal file
@ -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.
|
@ -16,7 +16,6 @@ import logging
|
|||||||
from typing import TYPE_CHECKING, Tuple
|
from typing import TYPE_CHECKING, Tuple
|
||||||
|
|
||||||
from synapse.api.constants import ReceiptTypes
|
from synapse.api.constants import ReceiptTypes
|
||||||
from synapse.api.errors import SynapseError
|
|
||||||
from synapse.http.server import HttpServer
|
from synapse.http.server import HttpServer
|
||||||
from synapse.http.servlet import RestServlet, parse_json_object_from_request
|
from synapse.http.servlet import RestServlet, parse_json_object_from_request
|
||||||
from synapse.http.site import SynapseRequest
|
from synapse.http.site import SynapseRequest
|
||||||
@ -50,17 +49,21 @@ class ReadMarkerRestServlet(RestServlet):
|
|||||||
|
|
||||||
body = parse_json_object_from_request(request)
|
body = parse_json_object_from_request(request)
|
||||||
|
|
||||||
valid_receipt_types = {ReceiptTypes.READ, ReceiptTypes.FULLY_READ}
|
valid_receipt_types = {
|
||||||
if self.config.experimental.msc2285_enabled:
|
ReceiptTypes.READ,
|
||||||
valid_receipt_types.add(ReceiptTypes.READ_PRIVATE)
|
ReceiptTypes.FULLY_READ,
|
||||||
|
ReceiptTypes.READ_PRIVATE,
|
||||||
|
}
|
||||||
|
|
||||||
if set(body.keys()) > valid_receipt_types:
|
unrecognized_types = set(body.keys()) - valid_receipt_types
|
||||||
raise SynapseError(
|
if unrecognized_types:
|
||||||
400,
|
# It's fine if there are unrecognized receipt types, but let's log
|
||||||
"Receipt type must be 'm.read', 'org.matrix.msc2285.read.private' or 'm.fully_read'"
|
# it to help debug clients that have typoed the receipt type.
|
||||||
if self.config.experimental.msc2285_enabled
|
#
|
||||||
else "Receipt type must be 'm.read' or 'm.fully_read'",
|
# 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)
|
read_event_id = body.get(ReceiptTypes.READ, None)
|
||||||
if read_event_id:
|
if read_event_id:
|
||||||
|
Loading…
Reference in New Issue
Block a user