summary refs log tree commit diff
path: root/synapse/events/builder.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-12-11 13:25:19 +0000
committerErik Johnston <erik@matrix.org>2014-12-11 13:25:19 +0000
commit8cdebce470869613658543cb79ed5dd97a5f0548 (patch)
treefda8993e709dcd1cea380df5db79bc6f202c3618 /synapse/events/builder.py
parentFix some tests (diff)
downloadsynapse-8cdebce470869613658543cb79ed5dd97a5f0548.tar.xz
Fix redactions. Fix 'age' key
Diffstat (limited to 'synapse/events/builder.py')
-rw-r--r--synapse/events/builder.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/synapse/events/builder.py b/synapse/events/builder.py
index 642264e9f3..9579b1fe8b 100644
--- a/synapse/events/builder.py
+++ b/synapse/events/builder.py
@@ -19,11 +19,18 @@ from synapse.types import EventID
 
 from synapse.util.stringutils import random_string
 
+import copy
+
 
 class EventBuilder(EventBase):
     def __init__(self, key_values={}):
+        signatures = copy.deepcopy(key_values.pop("signatures", {}))
+        unsigned = copy.deepcopy(key_values.pop("unsigned", {}))
+
         super(EventBuilder, self).__init__(
             key_values,
+            signatures=signatures,
+            unsigned=unsigned
         )
 
     def update_event_key(self, key, value):
@@ -61,9 +68,9 @@ class EventBuilderFactory(object):
         key_values.setdefault("origin", self.hostname)
         key_values.setdefault("origin_server_ts", time_now)
 
-        if "unsigned" in key_values:
-            age = key_values["unsigned"].pop("age", 0)
-            key_values["unsigned"].setdefault("age_ts", time_now - age)
+        key_values.setdefault("unsigned", {})
+        age = key_values["unsigned"].pop("age", 0)
+        key_values["unsigned"].setdefault("age_ts", time_now - age)
 
         key_values["signatures"] = {}