summary refs log tree commit diff
path: root/synapse/handlers/message.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/handlers/message.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/handlers/message.py')
-rw-r--r--synapse/handlers/message.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py
index 4e55ebba0b..15b828dd74 100644
--- a/synapse/handlers/message.py
+++ b/synapse/handlers/message.py
@@ -1360,8 +1360,16 @@ class EventCreationHandler:
             else:
                 try:
                     validate_event_for_room_version(event)
+                    # If we are persisting a batch of events the event(s) needed to auth the
+                    # current event may be part of the batch and will not be in the DB yet
+                    event_id_to_event = {e.event_id: e for e, _ in events_and_context}
+                    batched_auth_events = {}
+                    for event_id in event.auth_event_ids():
+                        auth_event = event_id_to_event.get(event_id)
+                        if auth_event:
+                            batched_auth_events[event_id] = auth_event
                     await self._event_auth_handler.check_auth_rules_from_context(
-                        event, context
+                        event, batched_auth_events
                     )
                 except AuthError as err:
                     logger.warning("Denying new event %r because %s", event, err)