summary refs log tree commit diff
diff options
context:
space:
mode:
authorMark Haines <mjark@negativecurvature.net>2015-12-14 15:48:00 +0000
committerMark Haines <mjark@negativecurvature.net>2015-12-14 15:48:00 +0000
commit910956b0ec900dd6fada6101337c62e378a60f97 (patch)
treebda7b53262063e6efc686362a05a68c6e389f341
parentMerge branch 'release-v0.12.0' into develop (diff)
parentFix spacing (diff)
downloadsynapse-910956b0ec900dd6fada6101337c62e378a60f97.tar.xz
Merge pull request #443 from matrix-org/markjh/commentary
Add commentary for fix in PR #442
-rw-r--r--synapse/rest/client/v2_alpha/sync.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/synapse/rest/client/v2_alpha/sync.py b/synapse/rest/client/v2_alpha/sync.py
index 3f8ce701dc..73b44e92eb 100644
--- a/synapse/rest/client/v2_alpha/sync.py
+++ b/synapse/rest/client/v2_alpha/sync.py
@@ -351,14 +351,27 @@ class SyncRestServlet(RestServlet):
                 continue
 
             prev_event_id = timeline_event.unsigned.get("replaces_state", None)
-            logger.debug("Replacing %s with %s in state dict",
-                         timeline_event.event_id, prev_event_id)
 
             prev_content = timeline_event.unsigned.get('prev_content')
             prev_sender = timeline_event.unsigned.get('prev_sender')
+            # Empircally it seems possible for the event to have a
+            # "replaces_state" key but not a prev_content or prev_sender
+            # markjh conjectures that it could be due to the server not
+            # having a copy of that event.
+            # If this is the case the we ignore the previous event. This will
+            # cause the displayname calculations on the client to be incorrect
             if prev_event_id is None or not prev_content or not prev_sender:
+                logger.debug(
+                    "Removing %r from the state dict, as it is missing"
+                    " prev_content (prev_event_id=%r)",
+                    timeline_event.event_id, prev_event_id
+                )
                 del result[event_key]
             else:
+                logger.debug(
+                    "Replacing %r with %r in state dict",
+                    timeline_event.event_id, prev_event_id
+                )
                 result[event_key] = FrozenEvent({
                     "type": timeline_event.type,
                     "state_key": timeline_event.state_key,