mirror of
https://github.com/element-hq/synapse
synced 2024-08-19 08:00:53 +00:00
make FederationHandler.persist_events_and_notify async
This commit is contained in:
parent
3b7e0e002b
commit
05299599b6
1 changed files with 10 additions and 10 deletions
|
@ -2816,27 +2816,27 @@ class FederationHandler(BaseHandler):
|
||||||
if "valid" not in response or not response["valid"]:
|
if "valid" not in response or not response["valid"]:
|
||||||
raise AuthError(403, "Third party certificate was invalid")
|
raise AuthError(403, "Third party certificate was invalid")
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
async def persist_events_and_notify(
|
||||||
def persist_events_and_notify(self, event_and_contexts, backfilled=False):
|
self,
|
||||||
|
event_and_contexts: Sequence[Tuple[EventBase, EventContext]],
|
||||||
|
backfilled: bool = False,
|
||||||
|
) -> None:
|
||||||
"""Persists events and tells the notifier/pushers about them, if
|
"""Persists events and tells the notifier/pushers about them, if
|
||||||
necessary.
|
necessary.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
event_and_contexts(list[tuple[FrozenEvent, EventContext]])
|
event_and_contexts:
|
||||||
backfilled (bool): Whether these events are a result of
|
backfilled: Whether these events are a result of
|
||||||
backfilling or not
|
backfilling or not
|
||||||
|
|
||||||
Returns:
|
|
||||||
Deferred
|
|
||||||
"""
|
"""
|
||||||
if self.config.worker_app:
|
if self.config.worker_app:
|
||||||
yield self._send_events_to_master(
|
await self._send_events_to_master(
|
||||||
store=self.store,
|
store=self.store,
|
||||||
event_and_contexts=event_and_contexts,
|
event_and_contexts=event_and_contexts,
|
||||||
backfilled=backfilled,
|
backfilled=backfilled,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
max_stream_id = yield self.storage.persistence.persist_events(
|
max_stream_id = await self.storage.persistence.persist_events(
|
||||||
event_and_contexts, backfilled=backfilled
|
event_and_contexts, backfilled=backfilled
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2847,7 +2847,7 @@ class FederationHandler(BaseHandler):
|
||||||
|
|
||||||
if not backfilled: # Never notify for backfilled events
|
if not backfilled: # Never notify for backfilled events
|
||||||
for event, _ in event_and_contexts:
|
for event, _ in event_and_contexts:
|
||||||
yield self._notify_persisted_event(event, max_stream_id)
|
await self._notify_persisted_event(event, max_stream_id)
|
||||||
|
|
||||||
def _notify_persisted_event(self, event, max_stream_id):
|
def _notify_persisted_event(self, event, max_stream_id):
|
||||||
"""Checks to see if notifier/pushers should be notified about the
|
"""Checks to see if notifier/pushers should be notified about the
|
||||||
|
|
Loading…
Reference in a new issue