diff options
author | H. Shay <hillerys@element.io> | 2022-10-05 13:50:29 -0700 |
---|---|---|
committer | H. Shay <hillerys@element.io> | 2022-10-05 13:50:29 -0700 |
commit | 157e4fdf814ada455c78ca84f8416fae61529c44 (patch) | |
tree | c8d08cefe06c8485a724939edf7fc09fffacfe2c | |
parent | update auth functions to take optional parameter of batched events needed to ... (diff) | |
download | synapse-157e4fdf814ada455c78ca84f8416fae61529c44.tar.xz |
when authing batched events, check if the events needed to auth the event are present in the batch and if so, pass them to the auth functions
-rw-r--r-- | synapse/handlers/message.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py index 00e7645ba5..dbea488ec4 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) |