diff options
author | Erik Johnston <erik@matrix.org> | 2019-01-23 20:21:33 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2019-01-25 10:32:19 +0000 |
commit | a50cf929c13044f25c3776802287458fe5695c37 (patch) | |
tree | 149d316c588f1a0629a90f44745e90f4a6ce5ff6 /synapse/federation/federation_base.py | |
parent | Merge pull request #4447 from matrix-org/erikj/msc_1813 (diff) | |
download | synapse-a50cf929c13044f25c3776802287458fe5695c37.tar.xz |
Require event format version to parse or create events
Diffstat (limited to 'synapse/federation/federation_base.py')
-rw-r--r-- | synapse/federation/federation_base.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/synapse/federation/federation_base.py b/synapse/federation/federation_base.py index d749bfdd3a..5c31e5f85f 100644 --- a/synapse/federation/federation_base.py +++ b/synapse/federation/federation_base.py @@ -23,7 +23,7 @@ from twisted.internet.defer import DeferredList from synapse.api.constants import MAX_DEPTH, EventTypes, Membership from synapse.api.errors import Codes, SynapseError from synapse.crypto.event_signing import check_event_content_hash -from synapse.events import FrozenEvent +from synapse.events import event_type_from_format_version from synapse.events.utils import prune_event from synapse.http.servlet import assert_params_in_dict from synapse.types import get_domain_from_id @@ -302,11 +302,12 @@ def _is_invite_via_3pid(event): ) -def event_from_pdu_json(pdu_json, outlier=False): +def event_from_pdu_json(pdu_json, event_format_version, outlier=False): """Construct a FrozenEvent from an event json received over federation Args: pdu_json (object): pdu as received over federation + event_format_version (int): The event format version outlier (bool): True to mark this event as an outlier Returns: @@ -330,8 +331,8 @@ def event_from_pdu_json(pdu_json, outlier=False): elif depth > MAX_DEPTH: raise SynapseError(400, "Depth too large", Codes.BAD_JSON) - event = FrozenEvent( - pdu_json + event = event_type_from_format_version(event_format_version)( + pdu_json, ) event.internal_metadata.outlier = outlier |