matrix-org / synapse

Synapse: Matrix homeserver written in Python/Twisted.
https://matrix-org.github.io/synapse
Apache License 2.0
11.82k stars 2.13k forks source link

Additional validation of receipts #16327

Closed clokep closed 1 year ago

clokep commented 1 year ago

This improves the error messages sent to clients if they send bogus receipts and would have made my life much easier when I was debugging something.

For federation the best we do is check that the server is in the room and drop it if not (this is similar to what we do for typing, see #13830.

This essentially expands the validation added in #14632, and somewhat backs out https://github.com/matrix-org/synapse/commit/9f797a24a452a513628263b1b03172cee20a9856, but I still don't understand how that could ever happen. (Note that instead of raising an error if the event is unknown, we instead ignore the receipt. This should also help in situations where a room is purged, kind of like #15464.)

Sorry for the large diff -- one of the commits in the middle moves some tests around.

clokep commented 1 year ago

Hm, this seems to have a failing complement test. Will need to look deeper into it.