summary refs log tree commit diff
path: root/synapse/events/utils.py
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-11-30 17:46:35 +0000
committerMark Haines <mark.haines@matrix.org>2015-11-30 17:46:35 +0000
commitbde8d78b8a19c941cef926d3e480c81555dbe993 (patch)
treeacb9976a8bbff1a4c1e461783aa5f65098051846 /synapse/events/utils.py
parentMerge pull request #397 from matrix-org/erikj/redaction_inequality (diff)
downloadsynapse-bde8d78b8a19c941cef926d3e480c81555dbe993.tar.xz
Copy rather than move the fields to shuffle between a v1 and a v2 event.
This should make all v1 APIs compatible with v2 clients. While still
allowing v1 clients to access the fields.

This makes the documentation easier since we can just document the v2
format and explain that some of the fields, in some of the APIs are
duplicated for backwards compatibility, rather than having to document
two separate event formats.
Diffstat (limited to 'synapse/events/utils.py')
-rw-r--r--synapse/events/utils.py14
1 files changed, 5 insertions, 9 deletions
diff --git a/synapse/events/utils.py b/synapse/events/utils.py
index 44cc1ef132..666df54114 100644
--- a/synapse/events/utils.py
+++ b/synapse/events/utils.py
@@ -100,22 +100,18 @@ def format_event_raw(d):
 
 
 def format_event_for_client_v1(d):
-    d["user_id"] = d.pop("sender", None)
+    d = format_event_for_client_v2(d)
+
+    d["user_id"] = d.get("sender", None)
 
-    move_keys = (
+    copy_keys = (
         "age", "redacted_because", "replaces_state", "prev_content",
         "invite_room_state",
     )
-    for key in move_keys:
+    for key in copy_keys:
         if key in d["unsigned"]:
             d[key] = d["unsigned"][key]
 
-    drop_keys = (
-        "auth_events", "prev_events", "hashes", "signatures", "depth",
-        "unsigned", "origin", "prev_state"
-    )
-    for key in drop_keys:
-        d.pop(key, None)
     return d