Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #5743 from matrix-org/erikj/log_origin_receipts_mi…
Browse files Browse the repository at this point in the history
…smatch
  • Loading branch information
anoadragon453 committed Feb 19, 2020
2 parents 88c3303 + 2276936 commit 915d3d6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
1 change: 1 addition & 0 deletions changelog.d/5743.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Log when we receive an event receipt from an unexpected origin.
35 changes: 22 additions & 13 deletions synapse/handlers/receipts.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
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__)

Expand All @@ -40,18 +40,27 @@ def __init__(self, hs):
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)

Expand Down

0 comments on commit 915d3d6

Please sign in to comment.