summary refs log tree commit diff
path: root/synapse/event_auth.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2022-06-09 15:51:34 +0100
committerRichard van der Hoff <richard@matrix.org>2022-06-12 23:13:09 +0100
commit68be42f6b6433e93c7dccc0eae70177500ca60bc (patch)
treec9f73fb98a172ebdab4a95c7007428946e8392b0 /synapse/event_auth.py
parentEventAuthTestCase: build events for the right room version (diff)
downloadsynapse-68be42f6b6433e93c7dccc0eae70177500ca60bc.tar.xz
Remove `room_version` param from `validate_event_for_room_version`
Instead, use the `room_version` property of the event we're validating.

The `room_version` was originally added as a parameter somewhere around #4482,
but really it's been redundant since #6875 added a `room_version` field to `EventBase`.
Diffstat (limited to 'synapse/event_auth.py')
-rw-r--r--synapse/event_auth.py12
1 files changed, 4 insertions, 8 deletions
diff --git a/synapse/event_auth.py b/synapse/event_auth.py
index 4c0b587a76..77f90558d8 100644
--- a/synapse/event_auth.py
+++ b/synapse/event_auth.py
@@ -45,9 +45,7 @@ if typing.TYPE_CHECKING:
 logger = logging.getLogger(__name__)
 
 
-def validate_event_for_room_version(
-    room_version_obj: RoomVersion, event: "EventBase"
-) -> None:
+def validate_event_for_room_version(event: "EventBase") -> None:
     """Ensure that the event complies with the limits, and has the right signatures
 
     NB: does not *validate* the signatures - it assumes that any signatures present
@@ -60,12 +58,10 @@ def validate_event_for_room_version(
     NB: This is used to check events that have been received over federation. As such,
     it can only enforce the checks specified in the relevant room version, to avoid
     a split-brain situation where some servers accept such events, and others reject
-    them.
-
-    TODO: consider moving this into EventValidator
+    them. See also EventValidator, which contains extra checks which are applied only to
+    locally-generated events.
 
     Args:
-        room_version_obj: the version of the room which contains this event
         event: the event to be checked
 
     Raises:
@@ -103,7 +99,7 @@ def validate_event_for_room_version(
             raise AuthError(403, "Event not signed by sending server")
 
     is_invite_via_allow_rule = (
-        room_version_obj.msc3083_join_rules
+        event.room_version.msc3083_join_rules
         and event.type == EventTypes.Member
         and event.membership == Membership.JOIN
         and EventContentFields.AUTHORISING_USER in event.content