summary refs log tree commit diff
path: root/synapse/event_auth.py
diff options
context:
space:
mode:
authorShay <hillerys@element.io>2022-10-18 09:58:47 -0700
committerGitHub <noreply@github.com>2022-10-18 09:58:47 -0700
commit847e2393f3198b88809c9b99de5c681efbf1c92e (patch)
tree3fa4d655c32a36dc741b70a008caa932deffafcb /synapse/event_auth.py
parentBump pygithub from 1.55 to 1.56 (#14206) (diff)
downloadsynapse-847e2393f3198b88809c9b99de5c681efbf1c92e.tar.xz
Prepatory work for adding power level event to batched events (#14214)
Diffstat (limited to 'synapse/event_auth.py')
-rw-r--r--synapse/event_auth.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/synapse/event_auth.py b/synapse/event_auth.py
index c7d5ef92fc..bab31e33c5 100644
--- a/synapse/event_auth.py
+++ b/synapse/event_auth.py
@@ -15,7 +15,18 @@
 
 import logging
 import typing
-from typing import Any, Collection, Dict, Iterable, List, Optional, Set, Tuple, Union
+from typing import (
+    Any,
+    Collection,
+    Dict,
+    Iterable,
+    List,
+    Mapping,
+    Optional,
+    Set,
+    Tuple,
+    Union,
+)
 
 from canonicaljson import encode_canonical_json
 from signedjson.key import decode_verify_key_bytes
@@ -134,6 +145,7 @@ def validate_event_for_room_version(event: "EventBase") -> None:
 async def check_state_independent_auth_rules(
     store: _EventSourceStore,
     event: "EventBase",
+    batched_auth_events: Optional[Mapping[str, "EventBase"]] = None,
 ) -> None:
     """Check that an event complies with auth rules that are independent of room state
 
@@ -143,6 +155,8 @@ async def check_state_independent_auth_rules(
     Args:
         store: the datastore; used to fetch the auth events for validation
         event: the event being checked.
+        batched_auth_events: if the event being authed is part of a batch, any events
+            from the same batch that may be necessary to auth the current event
 
     Raises:
         AuthError if the checks fail
@@ -162,6 +176,9 @@ async def check_state_independent_auth_rules(
         redact_behaviour=EventRedactBehaviour.as_is,
         allow_rejected=True,
     )
+    if batched_auth_events:
+        auth_events.update(batched_auth_events)
+
     room_id = event.room_id
     auth_dict: MutableStateMap[str] = {}
     expected_auth_types = auth_types_for_event(event.room_version, event)