mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-14 02:13:46 +01:00
Support MSC3289: Room version 8 (#10449)
This adds support for MSC3289: room version 8. This is room version 7 + MSC3083.
This commit is contained in:
parent
4578531002
commit
0c246dd4a0
9 changed files with 37 additions and 38 deletions
1
changelog.d/10449.bugfix
Normal file
1
changelog.d/10449.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Mark the experimental room version from [MSC2716](https://github.com/matrix-org/matrix-doc/pull/2716) as unstable.
|
1
changelog.d/10449.feature
Normal file
1
changelog.d/10449.feature
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Support [MSC3289: room version 8](https://github.com/matrix-org/matrix-doc/pull/3289).
|
|
@ -62,7 +62,7 @@ class JoinRules:
|
||||||
INVITE = "invite"
|
INVITE = "invite"
|
||||||
PRIVATE = "private"
|
PRIVATE = "private"
|
||||||
# As defined for MSC3083.
|
# As defined for MSC3083.
|
||||||
MSC3083_RESTRICTED = "restricted"
|
RESTRICTED = "restricted"
|
||||||
|
|
||||||
|
|
||||||
class RestrictedJoinRuleTypes:
|
class RestrictedJoinRuleTypes:
|
||||||
|
|
|
@ -177,20 +177,6 @@ class RoomVersions:
|
||||||
msc2403_knocking=False,
|
msc2403_knocking=False,
|
||||||
msc2716_historical=False,
|
msc2716_historical=False,
|
||||||
)
|
)
|
||||||
MSC3083 = RoomVersion(
|
|
||||||
"org.matrix.msc3083.v2",
|
|
||||||
RoomDisposition.UNSTABLE,
|
|
||||||
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,
|
|
||||||
msc2716_historical=False,
|
|
||||||
)
|
|
||||||
V7 = RoomVersion(
|
V7 = RoomVersion(
|
||||||
"7",
|
"7",
|
||||||
RoomDisposition.STABLE,
|
RoomDisposition.STABLE,
|
||||||
|
@ -207,7 +193,7 @@ class RoomVersions:
|
||||||
)
|
)
|
||||||
MSC2716 = RoomVersion(
|
MSC2716 = RoomVersion(
|
||||||
"org.matrix.msc2716",
|
"org.matrix.msc2716",
|
||||||
RoomDisposition.STABLE,
|
RoomDisposition.UNSTABLE,
|
||||||
EventFormatVersions.V3,
|
EventFormatVersions.V3,
|
||||||
StateResolutionVersions.V2,
|
StateResolutionVersions.V2,
|
||||||
enforce_key_validity=True,
|
enforce_key_validity=True,
|
||||||
|
@ -219,6 +205,20 @@ class RoomVersions:
|
||||||
msc2403_knocking=True,
|
msc2403_knocking=True,
|
||||||
msc2716_historical=True,
|
msc2716_historical=True,
|
||||||
)
|
)
|
||||||
|
V8 = RoomVersion(
|
||||||
|
"8",
|
||||||
|
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=True,
|
||||||
|
msc2716_historical=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
KNOWN_ROOM_VERSIONS: Dict[str, RoomVersion] = {
|
KNOWN_ROOM_VERSIONS: Dict[str, RoomVersion] = {
|
||||||
|
@ -231,9 +231,9 @@ KNOWN_ROOM_VERSIONS: Dict[str, RoomVersion] = {
|
||||||
RoomVersions.V5,
|
RoomVersions.V5,
|
||||||
RoomVersions.V6,
|
RoomVersions.V6,
|
||||||
RoomVersions.MSC2176,
|
RoomVersions.MSC2176,
|
||||||
RoomVersions.MSC3083,
|
|
||||||
RoomVersions.V7,
|
RoomVersions.V7,
|
||||||
RoomVersions.MSC2716,
|
RoomVersions.MSC2716,
|
||||||
|
RoomVersions.V8,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -370,10 +370,7 @@ def _is_membership_change_allowed(
|
||||||
raise AuthError(403, "You are banned from this room")
|
raise AuthError(403, "You are banned from this room")
|
||||||
elif join_rule == JoinRules.PUBLIC:
|
elif join_rule == JoinRules.PUBLIC:
|
||||||
pass
|
pass
|
||||||
elif (
|
elif room_version.msc3083_join_rules and join_rule == JoinRules.RESTRICTED:
|
||||||
room_version.msc3083_join_rules
|
|
||||||
and join_rule == JoinRules.MSC3083_RESTRICTED
|
|
||||||
):
|
|
||||||
# This is the same as public, but the event must contain a reference
|
# 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
|
# to the server who authorised the join. If the event does not contain
|
||||||
# the proper content it is rejected.
|
# the proper content it is rejected.
|
||||||
|
|
|
@ -240,7 +240,7 @@ class EventAuthHandler:
|
||||||
|
|
||||||
# If the join rule is not restricted, this doesn't apply.
|
# If the join rule is not restricted, this doesn't apply.
|
||||||
join_rules_event = await self._store.get_event(join_rules_event_id)
|
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(
|
async def get_rooms_that_allow_join(
|
||||||
self, state_ids: StateMap[str]
|
self, state_ids: StateMap[str]
|
||||||
|
|
|
@ -341,7 +341,7 @@ class PruneEventTestCase(unittest.TestCase):
|
||||||
"signatures": {},
|
"signatures": {},
|
||||||
"unsigned": {},
|
"unsigned": {},
|
||||||
},
|
},
|
||||||
room_version=RoomVersions.MSC3083,
|
room_version=RoomVersions.V8,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -231,13 +231,13 @@ class SpaceSummaryTestCase(unittest.HomeserverTestCase):
|
||||||
invited_room = self._create_room_with_join_rule(JoinRules.INVITE)
|
invited_room = self._create_room_with_join_rule(JoinRules.INVITE)
|
||||||
self.helper.invite(invited_room, targ=user2, tok=self.token)
|
self.helper.invite(invited_room, targ=user2, tok=self.token)
|
||||||
restricted_room = self._create_room_with_join_rule(
|
restricted_room = self._create_room_with_join_rule(
|
||||||
JoinRules.MSC3083_RESTRICTED,
|
JoinRules.RESTRICTED,
|
||||||
room_version=RoomVersions.MSC3083.identifier,
|
room_version=RoomVersions.V8.identifier,
|
||||||
allow=[],
|
allow=[],
|
||||||
)
|
)
|
||||||
restricted_accessible_room = self._create_room_with_join_rule(
|
restricted_accessible_room = self._create_room_with_join_rule(
|
||||||
JoinRules.MSC3083_RESTRICTED,
|
JoinRules.RESTRICTED,
|
||||||
room_version=RoomVersions.MSC3083.identifier,
|
room_version=RoomVersions.V8.identifier,
|
||||||
allow=[
|
allow=[
|
||||||
{
|
{
|
||||||
"type": RestrictedJoinRuleTypes.ROOM_MEMBERSHIP,
|
"type": RestrictedJoinRuleTypes.ROOM_MEMBERSHIP,
|
||||||
|
@ -459,13 +459,13 @@ class SpaceSummaryTestCase(unittest.HomeserverTestCase):
|
||||||
{
|
{
|
||||||
"room_id": restricted_room,
|
"room_id": restricted_room,
|
||||||
"world_readable": False,
|
"world_readable": False,
|
||||||
"join_rules": JoinRules.MSC3083_RESTRICTED,
|
"join_rules": JoinRules.RESTRICTED,
|
||||||
"allowed_spaces": [],
|
"allowed_spaces": [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"room_id": restricted_accessible_room,
|
"room_id": restricted_accessible_room,
|
||||||
"world_readable": False,
|
"world_readable": False,
|
||||||
"join_rules": JoinRules.MSC3083_RESTRICTED,
|
"join_rules": JoinRules.RESTRICTED,
|
||||||
"allowed_spaces": [self.room],
|
"allowed_spaces": [self.room],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -384,7 +384,7 @@ class EventAuthTestCase(unittest.TestCase):
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
event_auth.check(
|
event_auth.check(
|
||||||
RoomVersions.MSC3083,
|
RoomVersions.V8,
|
||||||
authorised_join_event,
|
authorised_join_event,
|
||||||
auth_events,
|
auth_events,
|
||||||
do_sig_check=False,
|
do_sig_check=False,
|
||||||
|
@ -400,7 +400,7 @@ class EventAuthTestCase(unittest.TestCase):
|
||||||
"@inviter:foo.test"
|
"@inviter:foo.test"
|
||||||
)
|
)
|
||||||
event_auth.check(
|
event_auth.check(
|
||||||
RoomVersions.MSC3083,
|
RoomVersions.V8,
|
||||||
_join_event(
|
_join_event(
|
||||||
pleb,
|
pleb,
|
||||||
additional_content={
|
additional_content={
|
||||||
|
@ -414,7 +414,7 @@ class EventAuthTestCase(unittest.TestCase):
|
||||||
# A join which is missing an authorised server is rejected.
|
# A join which is missing an authorised server is rejected.
|
||||||
with self.assertRaises(AuthError):
|
with self.assertRaises(AuthError):
|
||||||
event_auth.check(
|
event_auth.check(
|
||||||
RoomVersions.MSC3083,
|
RoomVersions.V8,
|
||||||
_join_event(pleb),
|
_join_event(pleb),
|
||||||
auth_events,
|
auth_events,
|
||||||
do_sig_check=False,
|
do_sig_check=False,
|
||||||
|
@ -427,7 +427,7 @@ class EventAuthTestCase(unittest.TestCase):
|
||||||
)
|
)
|
||||||
with self.assertRaises(AuthError):
|
with self.assertRaises(AuthError):
|
||||||
event_auth.check(
|
event_auth.check(
|
||||||
RoomVersions.MSC3083,
|
RoomVersions.V8,
|
||||||
_join_event(
|
_join_event(
|
||||||
pleb,
|
pleb,
|
||||||
additional_content={
|
additional_content={
|
||||||
|
@ -442,7 +442,7 @@ class EventAuthTestCase(unittest.TestCase):
|
||||||
# *would* be valid, but is sent be a different user.)
|
# *would* be valid, but is sent be a different user.)
|
||||||
with self.assertRaises(AuthError):
|
with self.assertRaises(AuthError):
|
||||||
event_auth.check(
|
event_auth.check(
|
||||||
RoomVersions.MSC3083,
|
RoomVersions.V8,
|
||||||
_member_event(
|
_member_event(
|
||||||
pleb,
|
pleb,
|
||||||
"join",
|
"join",
|
||||||
|
@ -459,7 +459,7 @@ class EventAuthTestCase(unittest.TestCase):
|
||||||
auth_events[("m.room.member", pleb)] = _member_event(pleb, "ban")
|
auth_events[("m.room.member", pleb)] = _member_event(pleb, "ban")
|
||||||
with self.assertRaises(AuthError):
|
with self.assertRaises(AuthError):
|
||||||
event_auth.check(
|
event_auth.check(
|
||||||
RoomVersions.MSC3083,
|
RoomVersions.V8,
|
||||||
authorised_join_event,
|
authorised_join_event,
|
||||||
auth_events,
|
auth_events,
|
||||||
do_sig_check=False,
|
do_sig_check=False,
|
||||||
|
@ -468,7 +468,7 @@ class EventAuthTestCase(unittest.TestCase):
|
||||||
# A user who left can re-join.
|
# A user who left can re-join.
|
||||||
auth_events[("m.room.member", pleb)] = _member_event(pleb, "leave")
|
auth_events[("m.room.member", pleb)] = _member_event(pleb, "leave")
|
||||||
event_auth.check(
|
event_auth.check(
|
||||||
RoomVersions.MSC3083,
|
RoomVersions.V8,
|
||||||
authorised_join_event,
|
authorised_join_event,
|
||||||
auth_events,
|
auth_events,
|
||||||
do_sig_check=False,
|
do_sig_check=False,
|
||||||
|
@ -478,7 +478,7 @@ class EventAuthTestCase(unittest.TestCase):
|
||||||
# be authorised since the user is already joined.)
|
# be authorised since the user is already joined.)
|
||||||
auth_events[("m.room.member", pleb)] = _member_event(pleb, "join")
|
auth_events[("m.room.member", pleb)] = _member_event(pleb, "join")
|
||||||
event_auth.check(
|
event_auth.check(
|
||||||
RoomVersions.MSC3083,
|
RoomVersions.V8,
|
||||||
_join_event(pleb),
|
_join_event(pleb),
|
||||||
auth_events,
|
auth_events,
|
||||||
do_sig_check=False,
|
do_sig_check=False,
|
||||||
|
@ -490,7 +490,7 @@ class EventAuthTestCase(unittest.TestCase):
|
||||||
pleb, "invite", sender=creator
|
pleb, "invite", sender=creator
|
||||||
)
|
)
|
||||||
event_auth.check(
|
event_auth.check(
|
||||||
RoomVersions.MSC3083,
|
RoomVersions.V8,
|
||||||
_join_event(pleb),
|
_join_event(pleb),
|
||||||
auth_events,
|
auth_events,
|
||||||
do_sig_check=False,
|
do_sig_check=False,
|
||||||
|
|
Loading…
Reference in a new issue