Merge pull request #5743 from matrix-org/erikj/log_origin_receipts_mismatch

Log when we receive receipt from a different origin
This commit is contained in:
Erik Johnston 2019-07-24 13:27:57 +01:00 committed by GitHub
commit 2276936bac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 13 deletions

1
changelog.d/5743.bugfix Normal file
View File

@ -0,0 +1 @@
Log when we receive an event receipt from an unexpected origin.

View File

@ -17,7 +17,7 @@ import logging
from twisted.internet import defer from twisted.internet import defer
from synapse.handlers._base import BaseHandler from synapse.handlers._base import BaseHandler
from synapse.types import ReadReceipt from synapse.types import ReadReceipt, get_domain_from_id
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -40,18 +40,27 @@ class ReceiptsHandler(BaseHandler):
def _received_remote_receipt(self, origin, content): def _received_remote_receipt(self, origin, content):
"""Called when we receive an EDU of type m.receipt from a remote HS. """Called when we receive an EDU of type m.receipt from a remote HS.
""" """
receipts = [ receipts = []
ReadReceipt( for room_id, room_values in content.items():
room_id=room_id, for receipt_type, users in room_values.items():
receipt_type=receipt_type, for user_id, user_values in users.items():
user_id=user_id, if get_domain_from_id(user_id) != origin:
event_ids=user_values["event_ids"], logger.info(
data=user_values.get("data", {}), "Received receipt for user %r from server %s, ignoring",
) user_id,
for room_id, room_values in content.items() origin,
for receipt_type, users in room_values.items() )
for user_id, user_values in users.items() 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) yield self._handle_new_receipts(receipts)