-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add support for room version 10 #13220
Changes from 4 commits
169fcbc
3e7242d
e2f3113
017cf51
808dd94
b071842
da2d7a2
65fd49e
77a1a57
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add support for room version 10. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,31 @@ def validate_event_for_room_version(event: "EventBase") -> None: | |
Raises: | ||
SynapseError if there is a problem with the event | ||
""" | ||
# Reject events with stringy power levels if required by room version | ||
if ( | ||
event.type == EventTypes.PowerLevels | ||
and event.room_version.msc3667_int_only_power_levels | ||
): | ||
for key, value in event.content.items(): | ||
if key in [ | ||
squahtx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"users_default", | ||
"events_default", | ||
"state_default", | ||
"ban", | ||
"reject", | ||
H-Shay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"kick", | ||
"invite", | ||
]: | ||
if not isinstance(value, int): | ||
raise AuthError(403, f"{value} must be an integer.") | ||
if key in ["events", "notifications"]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this not also need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to include
and 2. doesn't mention There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for pointing this out, I added users and removed the weaker check in |
||
if not isinstance(value, dict) or not all( | ||
isinstance(v, int) for v in value.values() | ||
): | ||
raise AuthError( | ||
403, f"{value} must be a dict with integers as values." | ||
) | ||
|
||
squahtx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
_check_size_limits(event) | ||
|
||
if not hasattr(event, "room_id"): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the check here because the spec seems to indicate that the power level check failure should be "rejected under the authorization rules " and this was an auth check function relating to room versions, so it seemed the appropriate place. If it's not I am happy to move it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this to
_check_power_levels
, where we apply the rest of the auth rules under item 10. in the spec (https://spec.matrix.org/latest/rooms/v10/#authorization-rules) ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, done in 808dd94.