summary refs log tree commit diff
path: root/synapse/federation/federation_client.py
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2015-11-13 17:26:59 +0000
committerPaul "LeoNerd" Evans <paul@matrix.org>2015-11-13 17:26:59 +0000
commit4fbe6ca4010f804d784e16255fe4c63b7f607c52 (patch)
tree6a483ad84dae70964241b918b98d2525038f2fb2 /synapse/federation/federation_client.py
parentMerge branch 'develop' into paul/tiny-fixes (diff)
parentMerge pull request #374 from matrix-org/daniel/guestleave (diff)
downloadsynapse-4fbe6ca4010f804d784e16255fe4c63b7f607c52.tar.xz
Merge branch 'develop' into paul/tiny-fixes
Diffstat (limited to '')
-rw-r--r--synapse/federation/federation_client.py36
1 files changed, 28 insertions, 8 deletions
diff --git a/synapse/federation/federation_client.py b/synapse/federation/federation_client.py
index 723f571284..d4f586fae7 100644
--- a/synapse/federation/federation_client.py
+++ b/synapse/federation/federation_client.py
@@ -26,7 +26,6 @@ from synapse.api.errors import (
 from synapse.util import unwrapFirstError
 from synapse.util.caches.expiringcache import ExpiringCache
 from synapse.util.logutils import log_function
-from synapse.util import third_party_invites
 from synapse.events import FrozenEvent
 import synapse.metrics
 
@@ -358,7 +357,8 @@ class FederationClient(FederationBase):
         defer.returnValue(signed_auth)
 
     @defer.inlineCallbacks
-    def make_membership_event(self, destinations, room_id, user_id, membership, content):
+    def make_membership_event(self, destinations, room_id, user_id, membership,
+                              content={},):
         """
         Creates an m.room.member event, with context, without participating in the room.
 
@@ -390,20 +390,17 @@ class FederationClient(FederationBase):
             if destination == self.server_name:
                 continue
 
-            args = {}
-            if third_party_invites.join_has_third_party_invite(content):
-                args = third_party_invites.extract_join_keys(
-                    content["third_party_invite"]
-                )
             try:
                 ret = yield self.transport_layer.make_membership_event(
-                    destination, room_id, user_id, membership, args
+                    destination, room_id, user_id, membership
                 )
 
                 pdu_dict = ret["event"]
 
                 logger.debug("Got response to make_%s: %s", membership, pdu_dict)
 
+                pdu_dict["content"].update(content)
+
                 defer.returnValue(
                     (destination, self.event_from_pdu_json(pdu_dict))
                 )
@@ -704,3 +701,26 @@ class FederationClient(FederationBase):
         event.internal_metadata.outlier = outlier
 
         return event
+
+    @defer.inlineCallbacks
+    def forward_third_party_invite(self, destinations, room_id, event_dict):
+        for destination in destinations:
+            if destination == self.server_name:
+                continue
+
+            try:
+                yield self.transport_layer.exchange_third_party_invite(
+                    destination=destination,
+                    room_id=room_id,
+                    event_dict=event_dict,
+                )
+                defer.returnValue(None)
+            except CodeMessageException:
+                raise
+            except Exception as e:
+                logger.exception(
+                    "Failed to send_third_party_invite via %s: %s",
+                    destination, e.message
+                )
+
+        raise RuntimeError("Failed to send to any server.")