summary refs log tree commit diff
path: root/synapse/federation/transaction_queue.py
diff options
context:
space:
mode:
authorTravis Ralston <travpc@gmail.com>2019-03-05 23:09:39 -0700
committerTravis Ralston <travpc@gmail.com>2019-03-05 23:41:22 -0700
commit88df3a43e17ef41832917228f54549acf302d438 (patch)
treeef36ba5ba2fafda72864bc61975dd60d4b6b071c /synapse/federation/transaction_queue.py
parentRevert "Attempt at fix 1" (diff)
downloadsynapse-88df3a43e17ef41832917228f54549acf302d438.tar.xz
Attempt 2 at fixing
Attempt 1 didn't work because the remote server isn't expecting to
receive a `leave` negotiation. Instead, we should try sending the
event over a transaction so that the remote can deal with it as it
would any other leave event.
Diffstat (limited to '')
-rw-r--r--synapse/federation/transaction_queue.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/synapse/federation/transaction_queue.py b/synapse/federation/transaction_queue.py
index e5e42c647d..824390291d 100644
--- a/synapse/federation/transaction_queue.py
+++ b/synapse/federation/transaction_queue.py
@@ -22,6 +22,7 @@ from prometheus_client import Counter
 from twisted.internet import defer
 
 import synapse.metrics
+from synapse.api.constants import EventTypes, Membership
 from synapse.api.errors import (
     FederationDeniedError,
     HttpResponseException,
@@ -36,6 +37,7 @@ from synapse.metrics import (
     sent_transactions_counter,
 )
 from synapse.metrics.background_process_metrics import run_as_background_process
+from synapse.types import UserID
 from synapse.util import logcontext
 from synapse.util.metrics import measure_func
 from synapse.util.retryutils import NotRetryingDestination, get_retry_limiter
@@ -202,6 +204,17 @@ class TransactionQueue(object):
                         destinations = yield self.state.get_current_hosts_in_room(
                             event.room_id, latest_event_ids=event.prev_event_ids(),
                         )
+
+                        # Special case leaves: We could be disinviting the host or
+                        # unbanning them, so send the event to the host if they are
+                        # not already in the list. The event affects their membership,
+                        # so they have a moderate right to know what's going on.
+                        if event.type == EventTypes.Member and (event.membership ==
+                                                                Membership.LEAVE):
+                            target_user = UserID.from_string(event.state_key)
+                            if target_user.domain not in destinations:
+                                destinations = set(destinations)
+                                destinations.add(target_user.domain)
                     except Exception:
                         logger.exception(
                             "Failed to calculate hosts in room for event: %s",