diff options
author | Erik Johnston <erik@matrix.org> | 2019-01-23 20:13:07 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2019-01-23 20:13:07 +0000 |
commit | 17898a5ba66c7bc15b105e13c735478d03c4a3a4 (patch) | |
tree | 8b53d79e3f0bc652a209f92763223d1a602b2db6 /synapse/federation | |
parent | Merge branch 'erikj/get_pdu_versions' into erikj/require_format_version (diff) | |
parent | Clarify the invite flows (diff) | |
download | synapse-17898a5ba66c7bc15b105e13c735478d03c4a3a4.tar.xz |
Merge branch 'erikj/fixup_rejecting_invites' of github.com:matrix-org/synapse into erikj/require_format_version
Diffstat (limited to 'synapse/federation')
-rw-r--r-- | synapse/federation/federation_client.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/synapse/federation/federation_client.py b/synapse/federation/federation_client.py index 28b6ee4ec8..9ba3e1c42f 100644 --- a/synapse/federation/federation_client.py +++ b/synapse/federation/federation_client.py @@ -37,7 +37,8 @@ from synapse.api.errors import ( HttpResponseException, SynapseError, ) -from synapse.events import builder, room_version_to_event_format +from synapse.events import room_version_to_event_format +from synapse.crypto.event_signing import add_hashes_and_signatures from synapse.federation.federation_base import FederationBase, event_from_pdu_json from synapse.util import logcontext, unwrapFirstError from synapse.util.caches.expiringcache import ExpiringCache @@ -71,6 +72,8 @@ class FederationClient(FederationBase): self.state = hs.get_state_handler() self.transport_layer = hs.get_federation_transport_client() + self.event_builder_factory = hs.get_event_builder_factory() + self._get_pdu_cache = ExpiringCache( cache_name="get_pdu_cache", clock=self._clock, @@ -594,7 +597,18 @@ class FederationClient(FederationBase): if "prev_state" not in pdu_dict: pdu_dict["prev_state"] = [] - ev = builder.EventBuilder(pdu_dict) + # Strip off the fields that we want to clobber. + pdu_dict.pop("origin", None) + pdu_dict.pop("origin_server_ts", None) + pdu_dict.pop("unsigned", None) + + builder = self.event_builder_factory.new(pdu_dict) + add_hashes_and_signatures( + builder, + self.hs.hostname, + self.hs.config.signing_key[0] + ) + ev = builder.build() defer.returnValue( (destination, ev, event_format) |