summary refs log tree commit diff
path: root/synapse/federation/transaction_queue.py
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2017-01-05 11:26:30 +0000
committerMark Haines <mark.haines@matrix.org>2017-01-05 11:26:30 +0000
commitf784980d2b2bd3827bfef94b0360582b2ef228ba (patch)
tree0cd29eea7e4aa805c39f6a8f14acc6b09c040f0b /synapse/federation/transaction_queue.py
parentMerge pull request #1758 from matrix-org/markjh/fix_ban_propagation (diff)
downloadsynapse-f784980d2b2bd3827bfef94b0360582b2ef228ba.tar.xz
Only send events that originate on this server.
Or events that are sent via the federation "send_join" API.

This should match the behaviour from before v0.18.5 and #1635 landed.
Diffstat (limited to 'synapse/federation/transaction_queue.py')
-rw-r--r--synapse/federation/transaction_queue.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/synapse/federation/transaction_queue.py b/synapse/federation/transaction_queue.py
index 891c245bb4..7db7b806dc 100644
--- a/synapse/federation/transaction_queue.py
+++ b/synapse/federation/transaction_queue.py
@@ -61,6 +61,7 @@ class TransactionQueue(object):
         self.transport_layer = hs.get_federation_transport_client()
 
         self.clock = hs.get_clock()
+        self.is_mine_id = hs.is_mine_id
 
         # Is a mapping from destinations -> deferreds. Used to keep track
         # of which destinations have transactions in flight and when they are
@@ -152,6 +153,12 @@ class TransactionQueue(object):
                     break
 
                 for event in events:
+                    # Only send events for this server.
+                    send_on_behalf_of = event.internal_metadata.get_send_on_behalf_of()
+                    is_mine = self.is_mine_id(event.event_id)
+                    if not is_mine and send_on_behalf_of is None:
+                        continue
+
                     # Get the state from before the event.
                     # We need to make sure that this is the state from before
                     # the event and not from after it.
@@ -167,6 +174,11 @@ class TransactionQueue(object):
                     destinations = set(
                         get_domain_from_id(user_id) for user_id in users_in_room
                     )
+                    if send_on_behalf_of is not None:
+                        # If we are sending the event on behalf of another server
+                        # then it already has the event and there is no reason to
+                        # send the event to it.
+                        destinations.discard(send_on_behalf_of)
 
                     logger.debug("Sending %s to %r", event, destinations)