summary refs log tree commit diff
path: root/synapse/handlers/federation.py
diff options
context:
space:
mode:
authorErik Johnston <erikj@jki.re>2019-01-25 10:26:13 +0000
committerGitHub <noreply@github.com>2019-01-25 10:26:13 +0000
commit829a7b20325aa35ecca11624baf68ebdb247e123 (patch)
tree08902e6b1564b865a5b21194c844d85a693ef095 /synapse/handlers/federation.py
parentMerge pull request #4451 from matrix-org/erikj/require_format_version (diff)
parentRevert "Require event format version to parse or create events" (diff)
downloadsynapse-829a7b20325aa35ecca11624baf68ebdb247e123.tar.xz
Merge pull request #4469 from matrix-org/revert-4451-erikj/require_format_version
Revert "Require event format version to parse or create events"
Diffstat (limited to 'synapse/handlers/federation.py')
-rw-r--r--synapse/handlers/federation.py72
1 files changed, 28 insertions, 44 deletions
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py
index a4b771049c..453d393ce1 100644
--- a/synapse/handlers/federation.py
+++ b/synapse/handlers/federation.py
@@ -1061,7 +1061,7 @@ class FederationHandler(BaseHandler):
         """
         logger.debug("Joining %s to %s", joinee, room_id)
 
-        origin, event, event_format_version = yield self._make_and_verify_event(
+        origin, event = yield self._make_and_verify_event(
             target_hosts,
             room_id,
             joinee,
@@ -1091,9 +1091,7 @@ class FederationHandler(BaseHandler):
                 target_hosts.insert(0, origin)
             except ValueError:
                 pass
-            ret = yield self.federation_client.send_join(
-                target_hosts, event, event_format_version,
-            )
+            ret = yield self.federation_client.send_join(target_hosts, event)
 
             origin = ret["origin"]
             state = ret["state"]
@@ -1166,18 +1164,13 @@ class FederationHandler(BaseHandler):
         """
         event_content = {"membership": Membership.JOIN}
 
-        room_version = yield self.store.get_room_version(room_id)
-
-        builder = self.event_builder_factory.new(
-            room_version,
-            {
-                "type": EventTypes.Member,
-                "content": event_content,
-                "room_id": room_id,
-                "sender": user_id,
-                "state_key": user_id,
-            }
-        )
+        builder = self.event_builder_factory.new({
+            "type": EventTypes.Member,
+            "content": event_content,
+            "room_id": room_id,
+            "sender": user_id,
+            "state_key": user_id,
+        })
 
         try:
             event, context = yield self.event_creation_handler.create_new_client_event(
@@ -1311,7 +1304,7 @@ class FederationHandler(BaseHandler):
 
     @defer.inlineCallbacks
     def do_remotely_reject_invite(self, target_hosts, room_id, user_id):
-        origin, event, event_format_version = yield self._make_and_verify_event(
+        origin, event = yield self._make_and_verify_event(
             target_hosts,
             room_id,
             user_id,
@@ -1343,7 +1336,7 @@ class FederationHandler(BaseHandler):
     @defer.inlineCallbacks
     def _make_and_verify_event(self, target_hosts, room_id, user_id, membership,
                                content={}, params=None):
-        origin, event, format_ver = yield self.federation_client.make_membership_event(
+        origin, pdu = yield self.federation_client.make_membership_event(
             target_hosts,
             room_id,
             user_id,
@@ -1352,7 +1345,9 @@ class FederationHandler(BaseHandler):
             params=params,
         )
 
-        logger.debug("Got response to make_%s: %s", membership, event)
+        logger.debug("Got response to make_%s: %s", membership, pdu)
+
+        event = pdu
 
         # We should assert some things.
         # FIXME: Do this in a nicer way
@@ -1360,7 +1355,7 @@ class FederationHandler(BaseHandler):
         assert(event.user_id == user_id)
         assert(event.state_key == user_id)
         assert(event.room_id == room_id)
-        defer.returnValue((origin, event, format_ver))
+        defer.returnValue((origin, event))
 
     @defer.inlineCallbacks
     @log_function
@@ -1369,17 +1364,13 @@ class FederationHandler(BaseHandler):
         leave event for the room and return that. We do *not* persist or
         process it until the other server has signed it and sent it back.
         """
-        room_version = yield self.store.get_room_version(room_id)
-        builder = self.event_builder_factory.new(
-            room_version,
-            {
-                "type": EventTypes.Member,
-                "content": {"membership": Membership.LEAVE},
-                "room_id": room_id,
-                "sender": user_id,
-                "state_key": user_id,
-            }
-        )
+        builder = self.event_builder_factory.new({
+            "type": EventTypes.Member,
+            "content": {"membership": Membership.LEAVE},
+            "room_id": room_id,
+            "sender": user_id,
+            "state_key": user_id,
+        })
 
         event, context = yield self.event_creation_handler.create_new_client_event(
             builder=builder,
@@ -2275,16 +2266,14 @@ class FederationHandler(BaseHandler):
         }
 
         if (yield self.auth.check_host_in_room(room_id, self.hs.hostname)):
-            room_version = yield self.store.get_room_version(room_id)
-            builder = self.event_builder_factory.new(room_version, event_dict)
-
+            builder = self.event_builder_factory.new(event_dict)
             EventValidator().validate_new(builder)
             event, context = yield self.event_creation_handler.create_new_client_event(
                 builder=builder
             )
 
             event, context = yield self.add_display_name_to_third_party_invite(
-                room_version, event_dict, event, context
+                event_dict, event, context
             )
 
             try:
@@ -2315,18 +2304,14 @@ class FederationHandler(BaseHandler):
         Returns:
             Deferred: resolves (to None)
         """
-        room_version = yield self.store.get_room_version(room_id)
-
-        # NB: event_dict has a particular specced format we might need to fudge
-        # if we change event formats too much.
-        builder = self.event_builder_factory.new(room_version, event_dict)
+        builder = self.event_builder_factory.new(event_dict)
 
         event, context = yield self.event_creation_handler.create_new_client_event(
             builder=builder,
         )
 
         event, context = yield self.add_display_name_to_third_party_invite(
-            room_version, event_dict, event, context
+            event_dict, event, context
         )
 
         try:
@@ -2346,8 +2331,7 @@ class FederationHandler(BaseHandler):
         yield member_handler.send_membership_event(None, event, context)
 
     @defer.inlineCallbacks
-    def add_display_name_to_third_party_invite(self, room_version, event_dict,
-                                               event, context):
+    def add_display_name_to_third_party_invite(self, event_dict, event, context):
         key = (
             EventTypes.ThirdPartyInvite,
             event.content["third_party_invite"]["signed"]["token"]
@@ -2371,7 +2355,7 @@ class FederationHandler(BaseHandler):
             # auth checks. If we need the invite and don't have it then the
             # auth check code will explode appropriately.
 
-        builder = self.event_builder_factory.new(room_version, event_dict)
+        builder = self.event_builder_factory.new(event_dict)
         EventValidator().validate_new(builder)
         event, context = yield self.event_creation_handler.create_new_client_event(
             builder=builder,