Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 902987c

Browse files
committed
Optionally pass in the event context to handle_new_event.
1 parent 4529915 commit 902987c

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

synapse/handlers/federation.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1994,13 +1994,36 @@ async def _handle_new_event(
19941994
self,
19951995
origin: str,
19961996
event: EventBase,
1997+
context: Optional[EventContext] = None,
19971998
state: Optional[Iterable[EventBase]] = None,
19981999
auth_events: Optional[MutableStateMap[EventBase]] = None,
19992000
backfilled: bool = False,
20002001
) -> EventContext:
2001-
context = await self._prep_event(
2002-
origin, event, state=state, auth_events=auth_events, backfilled=backfilled
2003-
)
2002+
"""
2003+
Process an event.
2004+
2005+
Args:
2006+
origin: The host the event originates from.
2007+
event: The event itself.
2008+
context: The event context, if available. Otherwise this is calculated
2009+
from state and auth_events.
2010+
state: The state events to calculate the event context from. This is
2011+
ignored if context is provided.
2012+
auth_events: The auth events to calculate the event context from. This is
2013+
ignored if context is provided.
2014+
backfilled: True if the event was backfilled.
2015+
2016+
Returns:
2017+
The event context.
2018+
"""
2019+
if not context:
2020+
context = await self._prep_event(
2021+
origin,
2022+
event,
2023+
state=state,
2024+
auth_events=auth_events,
2025+
backfilled=backfilled,
2026+
)
20042027

20052028
try:
20062029
if (

0 commit comments

Comments
 (0)