diff options
author | Eric Eastwood <erice@element.io> | 2022-01-19 18:45:23 -0600 |
---|---|---|
committer | Eric Eastwood <erice@element.io> | 2022-01-19 18:50:02 -0600 |
commit | a0321040581e0ad98dd576c9e948e343da686891 (patch) | |
tree | d6f85f0c3fc086199bb6bf20bd5a521340bd0e7f /synapse/handlers/message.py | |
parent | We only have to store the state_group for events created by create_event first (diff) | |
download | synapse-a0321040581e0ad98dd576c9e948e343da686891.tar.xz |
Only share auth_event_ids when sender and type matches
Diffstat (limited to 'synapse/handlers/message.py')
-rw-r--r-- | synapse/handlers/message.py | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py index 4f92a86f82..915ad4240a 100644 --- a/synapse/handlers/message.py +++ b/synapse/handlers/message.py @@ -884,6 +884,30 @@ class EventCreationHandler: assert ev.internal_metadata.stream_ordering return ev, ev.internal_metadata.stream_ordering + async def strip_auth_event_ids_for_given_event_builder( + self, + builder: EventBuilder, + prev_event_ids: List[str], + auth_event_ids: List[str], + depth: Optional[int] = None, + ) -> List[str]: + temp_event = await builder.build( + prev_event_ids=prev_event_ids, + auth_event_ids=auth_event_ids, + depth=depth, + ) + auth_events = await self.store.get_events_as_list(auth_event_ids) + # Create a StateMap[str] + auth_event_state_map = {(e.type, e.state_key): e.event_id for e in auth_events} + # Actually strip down and use the necessary auth events + stripped_auth_event_ids = self._event_auth_handler.compute_auth_events( + event=temp_event, + current_state_ids=auth_event_state_map, + for_verification=False, + ) + + return stripped_auth_event_ids + @measure_func("create_new_client_event") async def create_new_client_event( self, @@ -925,29 +949,19 @@ class EventCreationHandler: # For example, we don't need extra m.room.member that don't match event.sender full_state_ids_at_event = None if auth_event_ids is not None: - # If auth events are provided, prev events must be also. + # If auth events are provided, prev events must also be provided. # prev_event_ids could be an empty array though. assert prev_event_ids is not None # Copy the full auth state before it stripped down full_state_ids_at_event = auth_event_ids.copy() - temp_event = await builder.build( + auth_event_ids = await self.strip_auth_event_ids_for_given_event_builder( + builder=builder, prev_event_ids=prev_event_ids, auth_event_ids=auth_event_ids, depth=depth, ) - auth_events = await self.store.get_events_as_list(auth_event_ids) - # Create a StateMap[str] - auth_event_state_map = { - (e.type, e.state_key): e.event_id for e in auth_events - } - # Actually strip down and use the necessary auth events - auth_event_ids = self._event_auth_handler.compute_auth_events( - event=temp_event, - current_state_ids=auth_event_state_map, - for_verification=False, - ) if prev_event_ids is not None: assert ( |