summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--synapse/events/utils.py79
-rw-r--r--synapse/federation/federation_base.py16
2 files changed, 4 insertions, 91 deletions
diff --git a/synapse/events/utils.py b/synapse/events/utils.py
index 65a9f70982..1aa952150e 100644
--- a/synapse/events/utils.py
+++ b/synapse/events/utils.py
@@ -94,85 +94,6 @@ def prune_event(event):
     )
 
 
-def old_prune_event(event):
-    """This is an old and buggy version of the prune event function. The
-    difference between this and the new version is that when including dicts
-    in the content they were included as frozen_dicts rather than dicts. This
-    caused the JSON encoder to encode as a list of the keys rather than the
-    dict.
-    """
-    event_type = event.type
-
-    allowed_keys = [
-        "event_id",
-        "sender",
-        "room_id",
-        "hashes",
-        "signatures",
-        "content",
-        "type",
-        "state_key",
-        "depth",
-        "prev_events",
-        "prev_state",
-        "auth_events",
-        "origin",
-        "origin_server_ts",
-        "membership",
-    ]
-
-    event_dict = event.get_dict()
-
-    new_content = {}
-
-    def add_fields(*fields):
-        for field in fields:
-            if field in event.content:
-                # This is the line that is buggy: event.content may return
-                # a frozen_dict which the json encoders encode as lists rather
-                # than dicts.
-                new_content[field] = event.content[field]
-
-    if event_type == EventTypes.Member:
-        add_fields("membership")
-    elif event_type == EventTypes.Create:
-        add_fields("creator")
-    elif event_type == EventTypes.JoinRules:
-        add_fields("join_rule")
-    elif event_type == EventTypes.PowerLevels:
-        add_fields(
-            "users",
-            "users_default",
-            "events",
-            "events_default",
-            "events_default",
-            "state_default",
-            "ban",
-            "kick",
-            "redact",
-        )
-    elif event_type == EventTypes.Aliases:
-        add_fields("aliases")
-
-    allowed_fields = {
-        k: v
-        for k, v in event_dict.items()
-        if k in allowed_keys
-    }
-
-    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,
-        internal_metadata_dict=event.internal_metadata.get_dict()
-    )
-
-
 def format_event_raw(d):
     return d
 
diff --git a/synapse/federation/federation_base.py b/synapse/federation/federation_base.py
index d26a2396ac..27c5918e0f 100644
--- a/synapse/federation/federation_base.py
+++ b/synapse/federation/federation_base.py
@@ -16,7 +16,7 @@
 
 from twisted.internet import defer
 
-from synapse.events.utils import prune_event, old_prune_event
+from synapse.events.utils import prune_event
 
 from syutil.jsonutil import encode_canonical_json
 
@@ -96,18 +96,10 @@ class FederationBase(object):
         redacted_event = prune_event(pdu)
         redacted_pdu_json = redacted_event.get_pdu_json()
 
-        old_redacted = old_prune_event(pdu)
-        old_redacted_pdu_json = old_redacted.get_pdu_json()
-
         try:
-            try:
-                yield self.keyring.verify_json_for_server(
-                    pdu.origin, old_redacted_pdu_json
-                )
-            except SynapseError:
-                yield self.keyring.verify_json_for_server(
-                    pdu.origin, redacted_pdu_json
-                )
+            yield self.keyring.verify_json_for_server(
+                pdu.origin, redacted_pdu_json
+            )
         except SynapseError:
             logger.warn(
                 "Signature check failed for %s redacted to %s",