forked from MirrorHub/synapse
Don't fail on empty bodies when sending out read receipts (#10531)
Fixes a bug introduced in rc1 that would cause Synapse to 400 on read receipts requests with empty bodies. Broken in #10413
This commit is contained in:
parent
903db99ed5
commit
e8a3e81402
3 changed files with 14 additions and 1 deletions
1
changelog.d/10531.bugfix
Normal file
1
changelog.d/10531.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Fix a bug introduced in Synapse v1.40.0rc1 that would cause Synapse to respond with an error when clients would update their read receipts.
|
|
@ -43,7 +43,7 @@ class ReceiptRestServlet(RestServlet):
|
||||||
if receipt_type != "m.read":
|
if receipt_type != "m.read":
|
||||||
raise SynapseError(400, "Receipt type must be 'm.read'")
|
raise SynapseError(400, "Receipt type must be 'm.read'")
|
||||||
|
|
||||||
body = parse_json_object_from_request(request)
|
body = parse_json_object_from_request(request, allow_empty_body=True)
|
||||||
hidden = body.get(ReadReceiptEventFields.MSC2285_HIDDEN, False)
|
hidden = body.get(ReadReceiptEventFields.MSC2285_HIDDEN, False)
|
||||||
|
|
||||||
if not isinstance(hidden, bool):
|
if not isinstance(hidden, bool):
|
||||||
|
|
|
@ -418,6 +418,18 @@ class ReadReceiptsTestCase(unittest.HomeserverTestCase):
|
||||||
# Test that the first user can't see the other user's hidden read receipt
|
# Test that the first user can't see the other user's hidden read receipt
|
||||||
self.assertEqual(self._get_read_receipt(), None)
|
self.assertEqual(self._get_read_receipt(), None)
|
||||||
|
|
||||||
|
def test_read_receipt_with_empty_body(self):
|
||||||
|
# Send a message as the first user
|
||||||
|
res = self.helper.send(self.room_id, body="hello", tok=self.tok)
|
||||||
|
|
||||||
|
# Send a read receipt for this message with an empty body
|
||||||
|
channel = self.make_request(
|
||||||
|
"POST",
|
||||||
|
"/rooms/%s/receipt/m.read/%s" % (self.room_id, res["event_id"]),
|
||||||
|
access_token=self.tok2,
|
||||||
|
)
|
||||||
|
self.assertEqual(channel.code, 200)
|
||||||
|
|
||||||
def _get_read_receipt(self):
|
def _get_read_receipt(self):
|
||||||
"""Syncs and returns the read receipt."""
|
"""Syncs and returns the read receipt."""
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue