mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2025-03-10 07:29:20 -04:00
make FederationClient._do_send_invite async
This commit is contained in:
parent
146fec0820
commit
6bbd890f05
@ -53,6 +53,7 @@ from synapse.events import EventBase, builder, room_version_to_event_format
|
|||||||
from synapse.federation.federation_base import FederationBase, event_from_pdu_json
|
from synapse.federation.federation_base import FederationBase, event_from_pdu_json
|
||||||
from synapse.logging.context import make_deferred_yieldable
|
from synapse.logging.context import make_deferred_yieldable
|
||||||
from synapse.logging.utils import log_function
|
from synapse.logging.utils import log_function
|
||||||
|
from synapse.types import JsonDict
|
||||||
from synapse.util import unwrapFirstError
|
from synapse.util import unwrapFirstError
|
||||||
from synapse.util.caches.expiringcache import ExpiringCache
|
from synapse.util.caches.expiringcache import ExpiringCache
|
||||||
from synapse.util.retryutils import NotRetryingDestination
|
from synapse.util.retryutils import NotRetryingDestination
|
||||||
@ -682,23 +683,19 @@ class FederationClient(FederationBase):
|
|||||||
|
|
||||||
return pdu
|
return pdu
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
async def _do_send_invite(
|
||||||
def _do_send_invite(self, destination, pdu, room_version):
|
self, destination: str, pdu: EventBase, room_version: str
|
||||||
|
) -> JsonDict:
|
||||||
"""Actually sends the invite, first trying v2 API and falling back to
|
"""Actually sends the invite, first trying v2 API and falling back to
|
||||||
v1 API if necessary.
|
v1 API if necessary.
|
||||||
|
|
||||||
Args:
|
|
||||||
destination (str): Target server
|
|
||||||
pdu (FrozenEvent)
|
|
||||||
room_version (str)
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
dict: The event as a dict as returned by the remote server
|
The event as a dict as returned by the remote server
|
||||||
"""
|
"""
|
||||||
time_now = self._clock.time_msec()
|
time_now = self._clock.time_msec()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
content = yield self.transport_layer.send_invite_v2(
|
content = await self.transport_layer.send_invite_v2(
|
||||||
destination=destination,
|
destination=destination,
|
||||||
room_id=pdu.room_id,
|
room_id=pdu.room_id,
|
||||||
event_id=pdu.event_id,
|
event_id=pdu.event_id,
|
||||||
@ -737,7 +734,7 @@ class FederationClient(FederationBase):
|
|||||||
# Didn't work, try v1 API.
|
# Didn't work, try v1 API.
|
||||||
# Note the v1 API returns a tuple of `(200, content)`
|
# Note the v1 API returns a tuple of `(200, content)`
|
||||||
|
|
||||||
_, content = yield self.transport_layer.send_invite_v1(
|
_, content = await self.transport_layer.send_invite_v1(
|
||||||
destination=destination,
|
destination=destination,
|
||||||
room_id=pdu.room_id,
|
room_id=pdu.room_id,
|
||||||
event_id=pdu.event_id,
|
event_id=pdu.event_id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user