summary refs log tree commit diff
path: root/synapse/events/utils.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/utils.py
parentFix some tests (diff)
downloadsynapse-8cdebce470869613658543cb79ed5dd97a5f0548.tar.xz
Fix redactions. Fix 'age' key
Diffstat (limited to 'synapse/events/utils.py')
-rw-r--r--synapse/events/utils.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/synapse/events/utils.py b/synapse/events/utils.py
index f5e135e3d0..6d9c9352e2 100644
--- a/synapse/events/utils.py
+++ b/synapse/events/utils.py
@@ -80,6 +80,11 @@ def prune_event(event):
 
     allowed_fields["content"] = new_content
 
+    allowed_fields["unsigned"] = {}
+
+    if "age_ts" in event.unsigned:
+        allowed_fields["unsigned"]["age_ts"] = event.unsigned["age_ts"]
+
     return type(event)(allowed_fields)
 
 
@@ -97,4 +102,20 @@ def serialize_event(hs, e):
 
     d["user_id"] = d.pop("sender", None)
 
+    if "redacted_because" in e.unsigned:
+        d["redacted_because"] = serialize_event(
+            hs, e.unsigned["redacted_because"]
+        )
+
+        del d["unsigned"]["redacted_because"]
+
+    if "redacted_by" in e.unsigned:
+        d["redacted_by"] = e.unsigned["redacted_by"]
+        del d["unsigned"]["redacted_by"]
+
+    del d["auth_events"]
+    del d["prev_events"]
+    del d["hashes"]
+    del d["signatures"]
+
     return d