mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-16 05:53:50 +01:00
Add a new method to enqueue the device messages rather than sending a dummy EDU
This commit is contained in:
parent
2a0159b8ae
commit
43954d000e
3 changed files with 20 additions and 7 deletions
|
@ -137,6 +137,12 @@ class FederationClient(FederationBase):
|
||||||
self._transaction_queue.enqueue_edu(edu)
|
self._transaction_queue.enqueue_edu(edu)
|
||||||
return defer.succeed(None)
|
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
|
@log_function
|
||||||
def send_failure(self, failure, destination):
|
def send_failure(self, failure, destination):
|
||||||
self._transaction_queue.enqueue_failure(failure, destination)
|
self._transaction_queue.enqueue_failure(failure, destination)
|
||||||
|
|
|
@ -157,6 +157,17 @@ class TransactionQueue(object):
|
||||||
self._attempt_new_transaction, destination
|
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
|
@defer.inlineCallbacks
|
||||||
def _attempt_new_transaction(self, destination):
|
def _attempt_new_transaction(self, destination):
|
||||||
yield run_on_reactor()
|
yield run_on_reactor()
|
||||||
|
|
|
@ -112,10 +112,6 @@ class DeviceMessageHandler(object):
|
||||||
)
|
)
|
||||||
|
|
||||||
for destination in remote_messages.keys():
|
for destination in remote_messages.keys():
|
||||||
# Hack to send make synapse send a federation transaction
|
# Enqueue a new federation transaction to send the new
|
||||||
# to the remote servers.
|
# device messages to each remote destination.
|
||||||
self.federation.send_edu(
|
self.federation.send_device_messages(destination)
|
||||||
destination=destination,
|
|
||||||
edu_type="m.ping",
|
|
||||||
content={},
|
|
||||||
)
|
|
||||||
|
|
Loading…
Reference in a new issue