diff options
author | Erik Johnston <erik@matrix.org> | 2014-12-04 15:50:01 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2014-12-04 15:50:01 +0000 |
commit | c31dba86ec40853f27c70ae13409ca3332052cc1 (patch) | |
tree | ab5a11519590c3c8e2211aedd2b441a7ccc759d5 /synapse/federation | |
parent | Begin converting things to use the new Event structure (diff) | |
download | synapse-c31dba86ec40853f27c70ae13409ca3332052cc1.tar.xz |
Convert rest and handlers to use new event structure
Diffstat (limited to 'synapse/federation')
-rw-r--r-- | synapse/federation/replication.py | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/synapse/federation/replication.py b/synapse/federation/replication.py index bd56a4c108..b11df9e5c6 100644 --- a/synapse/federation/replication.py +++ b/synapse/federation/replication.py @@ -74,6 +74,7 @@ class ReplicationLayer(object): self._clock = hs.get_clock() self.event_factory = hs.get_event_factory() + self.event_builder_factory = hs.get_event_builder_factory() def set_handler(self, handler): """Sets the handler that the replication layer will use to communicate @@ -658,19 +659,14 @@ class ReplicationLayer(object): return "<ReplicationLayer(%s)>" % self.server_name def event_from_pdu_json(self, pdu_json, outlier=False): - #TODO: Check we have all the PDU keys here - pdu_json.setdefault("hashes", {}) - pdu_json.setdefault("signatures", {}) - sender = pdu_json.pop("sender", None) - if sender is not None: - pdu_json["user_id"] = sender - state_hash = pdu_json.get("unsigned", {}).pop("state_hash", None) - if state_hash is not None: - pdu_json["state_hash"] = state_hash - return self.event_factory.create_event( - pdu_json["type"], outlier=outlier, **pdu_json + builder = self.event_builder_factory.new( + pdu_json ) + builder.internal_metadata = outlier + + return builder.build() + class _TransactionQueue(object): """This class makes sure we only have one transaction in flight at |