summary refs log tree commit diff
path: root/synapse/events/utils.py
diff options
context:
space:
mode:
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