summary refs log tree commit diff
path: root/synapse/rest/client/v2_alpha/sync.py
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-12-14 14:09:21 +0000
committerMark Haines <mark.haines@matrix.org>2015-12-14 14:09:21 +0000
commit834924248f4034a209271828d7cca47eee01f328 (patch)
tree0815db0cd962f67bfe984fdad0b1922fe510f756 /synapse/rest/client/v2_alpha/sync.py
parentMerge pull request #437 from matrix-org/markjh/parallel_sync (diff)
downloadsynapse-834924248f4034a209271828d7cca47eee01f328.tar.xz
Check whether prev_content or prev_sender is set before trying to rollback state
Diffstat (limited to 'synapse/rest/client/v2_alpha/sync.py')
-rw-r--r--synapse/rest/client/v2_alpha/sync.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/synapse/rest/client/v2_alpha/sync.py b/synapse/rest/client/v2_alpha/sync.py
index f0a637a6da..7cba981c04 100644
--- a/synapse/rest/client/v2_alpha/sync.py
+++ b/synapse/rest/client/v2_alpha/sync.py
@@ -357,14 +357,19 @@ class SyncRestServlet(RestServlet):
             if prev_event_id is None:
                 del result[event_key]
             else:
-                result[event_key] = FrozenEvent({
-                    "type": timeline_event.type,
-                    "state_key": timeline_event.state_key,
-                    "content": timeline_event.unsigned['prev_content'],
-                    "sender": timeline_event.unsigned['prev_sender'],
-                    "event_id": prev_event_id,
-                    "room_id": timeline_event.room_id,
-                })
+                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]
             logger.debug("New value: %r", result.get(event_key))
 
         return result