0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-15 13:13:54 +01:00

Add a new method to enqueue the device messages rather than sending a dummy EDU

This commit is contained in:
Mark Haines 2016-09-07 16:10:51 +01:00
parent 2a0159b8ae
commit 43954d000e
3 changed files with 20 additions and 7 deletions

View file

@ -137,6 +137,12 @@ class FederationClient(FederationBase):
self._transaction_queue.enqueue_edu(edu)
return defer.succeed(None)
@log_function
def send_device_messages(self, destination):
"""Sends the device messages in the local database to the remote
destination"""
self._transaction_queue.enqueue_device_messages(destination)
@log_function
def send_failure(self, failure, destination):
self._transaction_queue.enqueue_failure(failure, destination)

View file

@ -157,6 +157,17 @@ class TransactionQueue(object):
self._attempt_new_transaction, destination
)
def enqueue_device_messages(self, destination):
if destination == self.server_name or destination == "localhost":
return
if not self.can_send_to(destination):
return
preserve_context_over_fn(
self._attempt_new_transaction, destination
)
@defer.inlineCallbacks
def _attempt_new_transaction(self, destination):
yield run_on_reactor()

View file

@ -112,10 +112,6 @@ class DeviceMessageHandler(object):
)
for destination in remote_messages.keys():
# Hack to send make synapse send a federation transaction
# to the remote servers.
self.federation.send_edu(
destination=destination,
edu_type="m.ping",
content={},
)
# Enqueue a new federation transaction to send the new
# device messages to each remote destination.
self.federation.send_device_messages(destination)