diff --git a/synapse/federation/federation_client.py b/synapse/federation/federation_client.py
index d974e920c..f5b430e04 100644
--- a/synapse/federation/federation_client.py
+++ b/synapse/federation/federation_client.py
@@ -364,7 +364,9 @@ class FederationClient(FederationBase):
 
             args = {}
             if third_party_invites.join_has_third_party_invite(content):
-                args = third_party_invites.extract_join_keys(content)
+                args = third_party_invites.extract_join_keys(
+                    content["third_party_invite"]
+                )
             try:
                 ret = yield self.transport_layer.make_join(
                     destination, room_id, user_id, args
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py
index bbb457e82..6936cdc5f 100644
--- a/synapse/handlers/room.py
+++ b/synapse/handlers/room.py
@@ -566,7 +566,7 @@ class RoomMemberHandler(BaseHandler):
         if invitee:
             # make sure it looks like a user ID; it'll throw if it's invalid.
             UserID.from_string(invitee)
-            yield self.handlers.message_handler.create_and_send_event(
+            yield self.hs.get_handlers().message_handler.create_and_send_event(
                 {
                     "type": EventTypes.Member,
                     "content": {
@@ -641,7 +641,7 @@ class RoomMemberHandler(BaseHandler):
                 user.to_string()
             )
         )
-        msg_handler = self.handlers.message_handler
+        msg_handler = self.hs.get_handlers().message_handler
         yield msg_handler.create_and_send_event(
             {
                 "type": EventTypes.ThirdPartyInvite,
diff --git a/synapse/util/third_party_invites.py b/synapse/util/third_party_invites.py
index 45ae31d80..41e597d5b 100644
--- a/synapse/util/third_party_invites.py
+++ b/synapse/util/third_party_invites.py
@@ -51,7 +51,7 @@ def join_has_third_party_invite(content):
 def extract_join_keys(src):
     return {
         key: value
-        for key, value in src["third_party_invite"].items()
+        for key, value in src.items()
         if key in JOIN_KEYS
     }