summary refs log tree commit diff
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-12-14 14:34:04 +0000
committerMark Haines <mark.haines@matrix.org>2015-12-14 14:34:04 +0000
commit070e28e203e52fd8968564bec8e73c96c1ab290b (patch)
treed8fb4ef07b22e4494a9daf0c00921a9f0c26ca9f
parentCheck whether prev_content or prev_sender is set before trying to rollback state (diff)
downloadsynapse-070e28e203e52fd8968564bec8e73c96c1ab290b.tar.xz
Combine the prev content tests
-rw-r--r--synapse/rest/client/v2_alpha/sync.py26
1 files changed, 12 insertions, 14 deletions
diff --git a/synapse/rest/client/v2_alpha/sync.py b/synapse/rest/client/v2_alpha/sync.py
index 7cba981c04..3f8ce701dc 100644
--- a/synapse/rest/client/v2_alpha/sync.py
+++ b/synapse/rest/client/v2_alpha/sync.py
@@ -354,22 +354,20 @@ class SyncRestServlet(RestServlet):
             logger.debug("Replacing %s with %s in state dict",
                          timeline_event.event_id, prev_event_id)
 
-            if prev_event_id is None:
+            prev_content = timeline_event.unsigned.get('prev_content')
+            prev_sender = timeline_event.unsigned.get('prev_sender')
+            if prev_event_id is None or not prev_content or not prev_sender:
                 del result[event_key]
             else:
-                prev_content = timeline_event.unsigned.get('prev_content')
-                prev_sender = timeline_event.unsigned.get('prev_sender')
-                if prev_content and prev_sender:
-                    result[event_key] = FrozenEvent({
-                        "type": timeline_event.type,
-                        "state_key": timeline_event.state_key,
-                        "content": prev_content,
-                        "sender": prev_sender,
-                        "event_id": prev_event_id,
-                        "room_id": timeline_event.room_id,
-                    })
-                else:
-                    del result[event_key]
+                result[event_key] = FrozenEvent({
+                    "type": timeline_event.type,
+                    "state_key": timeline_event.state_key,
+                    "content": prev_content,
+                    "sender": prev_sender,
+                    "event_id": prev_event_id,
+                    "room_id": timeline_event.room_id,
+                })
+
             logger.debug("New value: %r", result.get(event_key))
 
         return result