diff options
author | Erik Johnston <erik@matrix.org> | 2019-07-24 13:27:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-24 13:27:57 +0100 |
commit | 2276936bacdaa62d2fbda2d6bc77620cef15b6ea (patch) | |
tree | eabfb8f292d45b46af1257cd7a08a620e18a98fd /synapse | |
parent | Stop trying to fetch events with event_id=None. (#5753) (diff) | |
parent | Update changelog.d/5743.bugfix (diff) | |
download | synapse-2276936bacdaa62d2fbda2d6bc77620cef15b6ea.tar.xz |
Merge pull request #5743 from matrix-org/erikj/log_origin_receipts_mismatch
Log when we receive receipt from a different origin
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/handlers/receipts.py | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/synapse/handlers/receipts.py b/synapse/handlers/receipts.py index 218d60f0c3..73973502a4 100644 --- a/synapse/handlers/receipts.py +++ b/synapse/handlers/receipts.py @@ -17,7 +17,7 @@ import logging from twisted.internet import defer from synapse.handlers._base import BaseHandler -from synapse.types import ReadReceipt +from synapse.types import ReadReceipt, get_domain_from_id logger = logging.getLogger(__name__) @@ -40,18 +40,27 @@ class ReceiptsHandler(BaseHandler): def _received_remote_receipt(self, origin, content): """Called when we receive an EDU of type m.receipt from a remote HS. """ - receipts = [ - ReadReceipt( - room_id=room_id, - receipt_type=receipt_type, - user_id=user_id, - event_ids=user_values["event_ids"], - data=user_values.get("data", {}), - ) - for room_id, room_values in content.items() - for receipt_type, users in room_values.items() - for user_id, user_values in users.items() - ] + receipts = [] + for room_id, room_values in content.items(): + for receipt_type, users in room_values.items(): + for user_id, user_values in users.items(): + if get_domain_from_id(user_id) != origin: + logger.info( + "Received receipt for user %r from server %s, ignoring", + user_id, + origin, + ) + continue + + receipts.append( + ReadReceipt( + room_id=room_id, + receipt_type=receipt_type, + user_id=user_id, + event_ids=user_values["event_ids"], + data=user_values.get("data", {}), + ) + ) yield self._handle_new_receipts(receipts) |