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

Support MSC3289: Room version 8 #10449

Merged
merged 5 commits into from
Aug 9, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/10449.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support [MSC3289: room version 8](https:/matrix-org/matrix-doc/pull/3289).
2 changes: 1 addition & 1 deletion synapse/api/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class JoinRules:
INVITE = "invite"
PRIVATE = "private"
# As defined for MSC3083.
MSC3083_RESTRICTED = "restricted"
RESTRICTED = "restricted"


class RestrictedJoinRuleTypes:
Expand Down
26 changes: 13 additions & 13 deletions synapse/api/room_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,22 +177,22 @@ class RoomVersions:
msc2403_knocking=False,
msc2716_historical=False,
)
MSC3083 = RoomVersion(
"org.matrix.msc3083.v2",
RoomDisposition.UNSTABLE,
V7 = RoomVersion(
"7",
RoomDisposition.STABLE,
EventFormatVersions.V3,
StateResolutionVersions.V2,
enforce_key_validity=True,
special_case_aliases_auth=False,
strict_canonicaljson=True,
limit_notifications_power_levels=True,
msc2176_redaction_rules=False,
msc3083_join_rules=True,
msc2403_knocking=False,
msc3083_join_rules=False,
msc2403_knocking=True,
msc2716_historical=False,
)
V7 = RoomVersion(
"7",
MSC2716 = RoomVersion(
"org.matrix.msc2716",
RoomDisposition.STABLE,
EventFormatVersions.V3,
StateResolutionVersions.V2,
Expand All @@ -203,10 +203,10 @@ class RoomVersions:
msc2176_redaction_rules=False,
msc3083_join_rules=False,
msc2403_knocking=True,
msc2716_historical=False,
msc2716_historical=True,
)
MSC2716 = RoomVersion(
"org.matrix.msc2716",
V8 = RoomVersion(
clokep marked this conversation as resolved.
Show resolved Hide resolved
"8",
RoomDisposition.STABLE,
EventFormatVersions.V3,
StateResolutionVersions.V2,
Expand All @@ -215,9 +215,9 @@ class RoomVersions:
strict_canonicaljson=True,
limit_notifications_power_levels=True,
msc2176_redaction_rules=False,
msc3083_join_rules=False,
msc3083_join_rules=True,
msc2403_knocking=True,
msc2716_historical=True,
msc2716_historical=False,
)


Expand All @@ -231,9 +231,9 @@ class RoomVersions:
RoomVersions.V5,
RoomVersions.V6,
RoomVersions.MSC2176,
RoomVersions.MSC3083,
RoomVersions.V7,
RoomVersions.MSC2716,
RoomVersions.V8,
)
}

Expand Down
5 changes: 1 addition & 4 deletions synapse/event_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,7 @@ def _is_membership_change_allowed(
raise AuthError(403, "You are banned from this room")
elif join_rule == JoinRules.PUBLIC:
pass
elif (
room_version.msc3083_join_rules
and join_rule == JoinRules.MSC3083_RESTRICTED
):
elif room_version.msc3083_join_rules and join_rule == JoinRules.RESTRICTED:
# This is the same as public, but the event must contain a reference
# to the server who authorised the join. If the event does not contain
# the proper content it is rejected.
Expand Down
2 changes: 1 addition & 1 deletion synapse/handlers/event_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ async def has_restricted_join_rules(

# If the join rule is not restricted, this doesn't apply.
join_rules_event = await self._store.get_event(join_rules_event_id)
return join_rules_event.content.get("join_rule") == JoinRules.MSC3083_RESTRICTED
return join_rules_event.content.get("join_rule") == JoinRules.RESTRICTED

async def get_rooms_that_allow_join(
self, state_ids: StateMap[str]
Expand Down
2 changes: 1 addition & 1 deletion tests/events/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def test_join_rules(self):
"signatures": {},
"unsigned": {},
},
room_version=RoomVersions.MSC3083,
room_version=RoomVersions.V8,
)


Expand Down
12 changes: 6 additions & 6 deletions tests/handlers/test_space_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,13 @@ def test_filtering(self):
invited_room = self._create_room_with_join_rule(JoinRules.INVITE)
self.helper.invite(invited_room, targ=user2, tok=self.token)
restricted_room = self._create_room_with_join_rule(
JoinRules.MSC3083_RESTRICTED,
room_version=RoomVersions.MSC3083.identifier,
JoinRules.RESTRICTED,
room_version=RoomVersions.V8.identifier,
allow=[],
)
restricted_accessible_room = self._create_room_with_join_rule(
JoinRules.MSC3083_RESTRICTED,
room_version=RoomVersions.MSC3083.identifier,
JoinRules.RESTRICTED,
room_version=RoomVersions.V8.identifier,
allow=[
{
"type": RestrictedJoinRuleTypes.ROOM_MEMBERSHIP,
Expand Down Expand Up @@ -459,13 +459,13 @@ async def summarize_remote_room(
{
"room_id": restricted_room,
"world_readable": False,
"join_rules": JoinRules.MSC3083_RESTRICTED,
"join_rules": JoinRules.RESTRICTED,
"allowed_spaces": [],
},
{
"room_id": restricted_accessible_room,
"world_readable": False,
"join_rules": JoinRules.MSC3083_RESTRICTED,
"join_rules": JoinRules.RESTRICTED,
"allowed_spaces": [self.room],
},
{
Expand Down
18 changes: 9 additions & 9 deletions tests/test_event_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def test_join_rules_msc3083_restricted(self):
},
)
event_auth.check(
RoomVersions.MSC3083,
RoomVersions.V8,
authorised_join_event,
auth_events,
do_sig_check=False,
Expand All @@ -400,7 +400,7 @@ def test_join_rules_msc3083_restricted(self):
"@inviter:foo.test"
)
event_auth.check(
RoomVersions.MSC3083,
RoomVersions.V8,
_join_event(
pleb,
additional_content={
Expand All @@ -414,7 +414,7 @@ def test_join_rules_msc3083_restricted(self):
# A join which is missing an authorised server is rejected.
with self.assertRaises(AuthError):
event_auth.check(
RoomVersions.MSC3083,
RoomVersions.V8,
_join_event(pleb),
auth_events,
do_sig_check=False,
Expand All @@ -427,7 +427,7 @@ def test_join_rules_msc3083_restricted(self):
)
with self.assertRaises(AuthError):
event_auth.check(
RoomVersions.MSC3083,
RoomVersions.V8,
_join_event(
pleb,
additional_content={
Expand All @@ -442,7 +442,7 @@ def test_join_rules_msc3083_restricted(self):
# *would* be valid, but is sent be a different user.)
with self.assertRaises(AuthError):
event_auth.check(
RoomVersions.MSC3083,
RoomVersions.V8,
_member_event(
pleb,
"join",
Expand All @@ -459,7 +459,7 @@ def test_join_rules_msc3083_restricted(self):
auth_events[("m.room.member", pleb)] = _member_event(pleb, "ban")
with self.assertRaises(AuthError):
event_auth.check(
RoomVersions.MSC3083,
RoomVersions.V8,
authorised_join_event,
auth_events,
do_sig_check=False,
Expand All @@ -468,7 +468,7 @@ def test_join_rules_msc3083_restricted(self):
# A user who left can re-join.
auth_events[("m.room.member", pleb)] = _member_event(pleb, "leave")
event_auth.check(
RoomVersions.MSC3083,
RoomVersions.V8,
authorised_join_event,
auth_events,
do_sig_check=False,
Expand All @@ -478,7 +478,7 @@ def test_join_rules_msc3083_restricted(self):
# be authorised since the user is already joined.)
auth_events[("m.room.member", pleb)] = _member_event(pleb, "join")
event_auth.check(
RoomVersions.MSC3083,
RoomVersions.V8,
_join_event(pleb),
auth_events,
do_sig_check=False,
Expand All @@ -490,7 +490,7 @@ def test_join_rules_msc3083_restricted(self):
pleb, "invite", sender=creator
)
event_auth.check(
RoomVersions.MSC3083,
RoomVersions.V8,
_join_event(pleb),
auth_events,
do_sig_check=False,
Expand Down