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

Don't pull out the full state when creating an event #13281

Merged
merged 2 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/13281.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Don't pull out the full state when creating an event.
8 changes: 7 additions & 1 deletion synapse/events/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
RoomVersion,
)
from synapse.crypto.event_signing import add_hashes_and_signatures
from synapse.event_auth import auth_types_for_event
from synapse.events import EventBase, _EventInternalMetadata, make_event_from_dict
from synapse.state import StateHandler
from synapse.storage.databases.main import DataStore
from synapse.storage.state import StateFilter
from synapse.types import EventID, JsonDict
from synapse.util import Clock
from synapse.util.stringutils import random_string
Expand Down Expand Up @@ -121,7 +123,11 @@ async def build(
"""
if auth_event_ids is None:
state_ids = await self._state.compute_state_after_events(
self.room_id, prev_event_ids
self.room_id,
prev_event_ids,
state_filter=StateFilter.from_types(
auth_types_for_event(self.room_version, self)
),
)
auth_event_ids = self._event_auth_handler.compute_auth_events(
self, state_ids
Expand Down
3 changes: 2 additions & 1 deletion synapse/state/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ async def compute_state_after_events(
self,
room_id: str,
event_ids: Collection[str],
state_filter: Optional[StateFilter] = None,
) -> StateMap[str]:
"""Fetch the state after each of the given event IDs. Resolve them and return.

Expand All @@ -174,7 +175,7 @@ async def compute_state_after_events(
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe update the docstring to reflect the addition of state_filter as an optional parameter?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh woops, didn't see this, sorry!

logger.debug("calling resolve_state_groups from compute_state_after_events")
ret = await self.resolve_state_groups_for_events(room_id, event_ids)
return await ret.get_state(self._state_storage_controller, StateFilter.all())
return await ret.get_state(self._state_storage_controller, state_filter)

async def get_current_users_in_room(
self, room_id: str, latest_event_ids: List[str]
Expand Down