Just pass in the event

This commit is contained in:
Eric Eastwood
2026-07-09 17:48:20 -05:00
parent bf9ab2f2e0
commit c54c93b481
4 changed files with 18 additions and 21 deletions
+1 -1
View File
@@ -1366,8 +1366,8 @@ class FederationClient(FederationBase):
#
# Find the full events based on the state at the time of the invite
state_ids = await self.store.get_stripped_room_state_ids_from_event_context(
pdu,
context,
self.store.calculate_stripped_state_filter(inviter_user_id=pdu.sender),
)
state_events = await self.store.get_events(state_ids)
assert set(state_ids) == set(state_events.keys()), (
+2 -6
View File
@@ -1020,7 +1020,7 @@ class FederationServer(FederationBase):
"""
time_now = self._clock.time_msec()
_, context = await self._on_send_membership_event(
event, context = await self._on_send_membership_event(
origin, content, Membership.KNOCK, room_id
)
@@ -1029,11 +1029,7 @@ class FederationServer(FederationBase):
#
# Find the full events based on the state at the time of the knock
state_ids = await self.store.get_stripped_room_state_ids_from_event_context(
context,
self.store.calculate_stripped_state_filter(
# None as this is a knock, not an invite
inviter_user_id=None
),
event, context
)
state_events = await self.store.get_events(state_ids)
assert set(state_ids) == set(state_events.keys()), (
+2 -7
View File
@@ -2076,10 +2076,8 @@ class EventCreationHandler:
event.unsigned,
"invite_room_state",
await self.store.get_stripped_room_state_from_event_context(
event,
context,
self.store.calculate_stripped_state_filter(
inviter_user_id=event.sender
),
),
)
@@ -2102,11 +2100,8 @@ class EventCreationHandler:
event.unsigned,
"knock_room_state",
await self.store.get_stripped_room_state_from_event_context(
event,
context,
self.store.calculate_stripped_state_filter(
# None as this is a knock, not an invite
inviter_user_id=None
),
),
)
@@ -41,7 +41,7 @@ from typing_extensions import assert_never
from twisted.internet import defer
from synapse.api.constants import Direction, EventTypes
from synapse.api.constants import Direction, EventTypes, Membership
from synapse.api.errors import NotFoundError, SynapseError
from synapse.api.room_versions import (
KNOWN_ROOM_VERSIONS,
@@ -1127,7 +1127,7 @@ class EventsWorkerStore(SQLBaseStore):
return event_map
def calculate_stripped_state_filter(
def _calculate_stripped_state_filter(
self,
*,
inviter_user_id: str | None = None,
@@ -1157,8 +1157,8 @@ class EventsWorkerStore(SQLBaseStore):
async def get_stripped_room_state_from_event_context(
self,
event: EventBase,
context: EventContext,
state_keys_to_include: StateFilter,
) -> list[JsonDict]:
"""
Retrieve the stripped state from a room, given an event context to retrieve state
@@ -1174,9 +1174,8 @@ class EventsWorkerStore(SQLBaseStore):
Returns:
A list of dictionaries, each representing a stripped state event from the room.
"""
selected_state_ids = await self.get_stripped_room_state_ids_from_event_context(
context, state_keys_to_include
event, context
)
state_to_include = await self.get_events(selected_state_ids)
@@ -1185,8 +1184,8 @@ class EventsWorkerStore(SQLBaseStore):
async def get_stripped_room_state_ids_from_event_context(
self,
event: EventBase,
context: EventContext,
state_keys_to_include: StateFilter,
) -> list[str]:
"""
Retrieve the stripped state IDs for an event, given an event context to retrieve state
@@ -1197,11 +1196,18 @@ class EventsWorkerStore(SQLBaseStore):
Args:
context: The event context to retrieve state of the room from.
state_keys_to_include: The state events to include, for each event type.
Returns:
A list of event_ids, each representing the stripped state event to include for this event
"""
is_invite_event = (
event.type == EventTypes.Member and event.membership == Membership.INVITE
)
# Get the relevant state
state_keys_to_include = self._calculate_stripped_state_filter(
inviter_user_id=event.sender if is_invite_event else None
)
selected_state_ids = await context.get_current_state_ids(state_keys_to_include)
# We know this event is not an outlier, so this must be