summary refs log tree commit diff
path: root/synapse/event_auth.py
diff options
context:
space:
mode:
authorShay <hillerys@element.io>2023-03-07 13:54:39 -0800
committerGitHub <noreply@github.com>2023-03-07 13:54:39 -0800
commita368d30c1cfe7457fca4fcdd03ae481ba65a226c (patch)
tree9b7e69974604f0d7f73ef88617bfbfe8e1d8db33 /synapse/event_auth.py
parentStabilize support for MSC3873: disambuguated event push keys. (#15190) (diff)
downloadsynapse-a368d30c1cfe7457fca4fcdd03ae481ba65a226c.tar.xz
More speedups/fixes to creating batched events (#15195)
Diffstat (limited to 'synapse/event_auth.py')
-rw-r--r--synapse/event_auth.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/synapse/event_auth.py b/synapse/event_auth.py

index 4d6d1b8ebd..af55874b5c 100644 --- a/synapse/event_auth.py +++ b/synapse/event_auth.py
@@ -168,13 +168,24 @@ async def check_state_independent_auth_rules( return # 2. Reject if event has auth_events that: ... - auth_events = await store.get_events( - event.auth_event_ids(), - redact_behaviour=EventRedactBehaviour.as_is, - allow_rejected=True, - ) if batched_auth_events: - auth_events.update(batched_auth_events) + # Copy the batched auth events to avoid mutating them. + auth_events = dict(batched_auth_events) + needed_auth_event_ids = set(event.auth_event_ids()) - batched_auth_events.keys() + if needed_auth_event_ids: + auth_events.update( + await store.get_events( + needed_auth_event_ids, + redact_behaviour=EventRedactBehaviour.as_is, + allow_rejected=True, + ) + ) + else: + auth_events = await store.get_events( + event.auth_event_ids(), + redact_behaviour=EventRedactBehaviour.as_is, + allow_rejected=True, + ) room_id = event.room_id auth_dict: MutableStateMap[str] = {}