Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Remove redundant room_version param from `check_auth_rules_from_con…
Browse files Browse the repository at this point in the history
…text`

It's now implied by the room_version property on the event.
  • Loading branch information
richvdh committed Jun 10, 2022
1 parent d0ce840 commit b35d990
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 34 deletions.
1 change: 0 additions & 1 deletion synapse/handlers/event_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def __init__(self, hs: "HomeServer"):

async def check_auth_rules_from_context(
self,
room_version_obj: RoomVersion,
event: EventBase,
context: EventContext,
) -> None:
Expand Down
18 changes: 5 additions & 13 deletions synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,9 +800,7 @@ async def on_make_join_request(

# The remote hasn't signed it yet, obviously. We'll do the full checks
# when we get the event back in `on_send_join_request`
await self._event_auth_handler.check_auth_rules_from_context(
room_version, event, context
)
await self._event_auth_handler.check_auth_rules_from_context(event, context)
return event

async def on_invite_request(
Expand Down Expand Up @@ -973,9 +971,7 @@ async def on_make_leave_request(
try:
# The remote hasn't signed it yet, obviously. We'll do the full checks
# when we get the event back in `on_send_leave_request`
await self._event_auth_handler.check_auth_rules_from_context(
room_version_obj, event, context
)
await self._event_auth_handler.check_auth_rules_from_context(event, context)
except AuthError as e:
logger.warning("Failed to create new leave %r because %s", event, e)
raise e
Expand Down Expand Up @@ -1034,9 +1030,7 @@ async def on_make_knock_request(
try:
# The remote hasn't signed it yet, obviously. We'll do the full checks
# when we get the event back in `on_send_knock_request`
await self._event_auth_handler.check_auth_rules_from_context(
room_version_obj, event, context
)
await self._event_auth_handler.check_auth_rules_from_context(event, context)
except AuthError as e:
logger.warning("Failed to create new knock %r because %s", event, e)
raise e
Expand Down Expand Up @@ -1209,7 +1203,7 @@ async def exchange_third_party_invite(
try:
validate_event_for_room_version(event)
await self._event_auth_handler.check_auth_rules_from_context(
room_version_obj, event, context
event, context
)
except AuthError as e:
logger.warning("Denying new third party invite %r because %s", event, e)
Expand Down Expand Up @@ -1260,9 +1254,7 @@ async def on_exchange_third_party_invite_request(

try:
validate_event_for_room_version(event)
await self._event_auth_handler.check_auth_rules_from_context(
room_version_obj, event, context
)
await self._event_auth_handler.check_auth_rules_from_context(event, context)
except AuthError as e:
logger.warning("Denying third party invite %r because %s", event, e)
raise e
Expand Down
19 changes: 1 addition & 18 deletions synapse/handlers/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -1274,23 +1274,6 @@ async def handle_new_client_event(
)
return prev_event

if event.is_state() and (event.type, event.state_key) == (
EventTypes.Create,
"",
):
room_version_id = event.content.get(
"room_version", RoomVersions.V1.identifier
)
maybe_room_version_obj = KNOWN_ROOM_VERSIONS.get(room_version_id)
if not maybe_room_version_obj:
raise UnsupportedRoomVersionError(
"Attempt to create a room with unsupported room version %s"
% (room_version_id,)
)
room_version_obj = maybe_room_version_obj
else:
room_version_obj = await self.store.get_room_version(event.room_id)

if event.internal_metadata.is_out_of_band_membership():
# the only sort of out-of-band-membership events we expect to see here are
# invite rejections and rescinded knocks that we have generated ourselves.
Expand All @@ -1300,7 +1283,7 @@ async def handle_new_client_event(
try:
validate_event_for_room_version(event)
await self._event_auth_handler.check_auth_rules_from_context(
room_version_obj, event, context
event, context
)
except AuthError as err:
logger.warning("Denying new event %r because %s", event, err)
Expand Down
3 changes: 1 addition & 2 deletions synapse/handlers/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,9 @@ async def upgrade_room(
},
},
)
old_room_version = await self.store.get_room_version(old_room_id)
validate_event_for_room_version(tombstone_event)
await self._event_auth_handler.check_auth_rules_from_context(
old_room_version, tombstone_event, tombstone_context
tombstone_event, tombstone_context
)

# Upgrade the room
Expand Down

0 comments on commit b35d990

Please sign in to comment.