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

Commit c6a0506

Browse files
authored
Don't pull out the full state when creating an event (#13281)
1 parent efee345 commit c6a0506

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

changelog.d/13281.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Don't pull out the full state when creating an event.

synapse/events/builder.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424
RoomVersion,
2525
)
2626
from synapse.crypto.event_signing import add_hashes_and_signatures
27+
from synapse.event_auth import auth_types_for_event
2728
from synapse.events import EventBase, _EventInternalMetadata, make_event_from_dict
2829
from synapse.state import StateHandler
2930
from synapse.storage.databases.main import DataStore
31+
from synapse.storage.state import StateFilter
3032
from synapse.types import EventID, JsonDict
3133
from synapse.util import Clock
3234
from synapse.util.stringutils import random_string
@@ -121,7 +123,11 @@ async def build(
121123
"""
122124
if auth_event_ids is None:
123125
state_ids = await self._state.compute_state_after_events(
124-
self.room_id, prev_event_ids
126+
self.room_id,
127+
prev_event_ids,
128+
state_filter=StateFilter.from_types(
129+
auth_types_for_event(self.room_version, self)
130+
),
125131
)
126132
auth_event_ids = self._event_auth_handler.compute_auth_events(
127133
self, state_ids

synapse/state/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ async def compute_state_after_events(
157157
self,
158158
room_id: str,
159159
event_ids: Collection[str],
160+
state_filter: Optional[StateFilter] = None,
160161
) -> StateMap[str]:
161162
"""Fetch the state after each of the given event IDs. Resolve them and return.
162163
@@ -174,7 +175,7 @@ async def compute_state_after_events(
174175
"""
175176
logger.debug("calling resolve_state_groups from compute_state_after_events")
176177
ret = await self.resolve_state_groups_for_events(room_id, event_ids)
177-
return await ret.get_state(self._state_storage_controller, StateFilter.all())
178+
return await ret.get_state(self._state_storage_controller, state_filter)
178179

179180
async def get_current_users_in_room(
180181
self, room_id: str, latest_event_ids: List[str]

0 commit comments

Comments
 (0)