Skip to content

Commit

Permalink
update only if needed auth events exist
Browse files Browse the repository at this point in the history
  • Loading branch information
ggogel committed Mar 9, 2024
1 parent c6a0de8 commit 4a3e6c7
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions synapse/event_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,23 +189,20 @@ async def check_state_independent_auth_rules(
# 2. Reject if event has auth_events that: ...
auth_events: MutableMapping[str, "EventBase"] = {}
if batched_auth_events:
auth_events = cast(MutableMapping[str, "EventBase"], batched_auth_events)
needed_auth_event_ids = [
event_id
for event_id in event.auth_event_ids()
if event_id not in batched_auth_events
]

needed_auth_events: MutableMapping[str, "EventBase"] = {}

if needed_auth_event_ids:
needed_auth_events = await store.get_events(
needed_auth_event_ids,
redact_behaviour=EventRedactBehaviour.as_is,
allow_rejected=True,
auth_events.update(
await store.get_events(
needed_auth_event_ids,
redact_behaviour=EventRedactBehaviour.as_is,
allow_rejected=True,
)
)

auth_events = cast(MutableMapping[str, "EventBase"], batched_auth_events)
auth_events.update(needed_auth_events)
else:
auth_events = await store.get_events(
event.auth_event_ids(),
Expand Down

0 comments on commit 4a3e6c7

Please sign in to comment.