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

Commit 0c246dd

Browse files
authored
Support MSC3289: Room version 8 (#10449)
This adds support for MSC3289: room version 8. This is room version 7 + MSC3083.
1 parent 4578531 commit 0c246dd

File tree

9 files changed

+35
-36
lines changed

9 files changed

+35
-36
lines changed

changelog.d/10449.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Mark the experimental room version from [MSC2716](https://github.com/matrix-org/matrix-doc/pull/2716) as unstable.

changelog.d/10449.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Support [MSC3289: room version 8](https://github.com/matrix-org/matrix-doc/pull/3289).

synapse/api/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class JoinRules:
6262
INVITE = "invite"
6363
PRIVATE = "private"
6464
# As defined for MSC3083.
65-
MSC3083_RESTRICTED = "restricted"
65+
RESTRICTED = "restricted"
6666

6767

6868
class RestrictedJoinRuleTypes:

synapse/api/room_versions.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -177,23 +177,23 @@ class RoomVersions:
177177
msc2403_knocking=False,
178178
msc2716_historical=False,
179179
)
180-
MSC3083 = RoomVersion(
181-
"org.matrix.msc3083.v2",
182-
RoomDisposition.UNSTABLE,
180+
V7 = RoomVersion(
181+
"7",
182+
RoomDisposition.STABLE,
183183
EventFormatVersions.V3,
184184
StateResolutionVersions.V2,
185185
enforce_key_validity=True,
186186
special_case_aliases_auth=False,
187187
strict_canonicaljson=True,
188188
limit_notifications_power_levels=True,
189189
msc2176_redaction_rules=False,
190-
msc3083_join_rules=True,
191-
msc2403_knocking=False,
190+
msc3083_join_rules=False,
191+
msc2403_knocking=True,
192192
msc2716_historical=False,
193193
)
194-
V7 = RoomVersion(
195-
"7",
196-
RoomDisposition.STABLE,
194+
MSC2716 = RoomVersion(
195+
"org.matrix.msc2716",
196+
RoomDisposition.UNSTABLE,
197197
EventFormatVersions.V3,
198198
StateResolutionVersions.V2,
199199
enforce_key_validity=True,
@@ -203,10 +203,10 @@ class RoomVersions:
203203
msc2176_redaction_rules=False,
204204
msc3083_join_rules=False,
205205
msc2403_knocking=True,
206-
msc2716_historical=False,
206+
msc2716_historical=True,
207207
)
208-
MSC2716 = RoomVersion(
209-
"org.matrix.msc2716",
208+
V8 = RoomVersion(
209+
"8",
210210
RoomDisposition.STABLE,
211211
EventFormatVersions.V3,
212212
StateResolutionVersions.V2,
@@ -215,9 +215,9 @@ class RoomVersions:
215215
strict_canonicaljson=True,
216216
limit_notifications_power_levels=True,
217217
msc2176_redaction_rules=False,
218-
msc3083_join_rules=False,
218+
msc3083_join_rules=True,
219219
msc2403_knocking=True,
220-
msc2716_historical=True,
220+
msc2716_historical=False,
221221
)
222222

223223

@@ -231,9 +231,9 @@ class RoomVersions:
231231
RoomVersions.V5,
232232
RoomVersions.V6,
233233
RoomVersions.MSC2176,
234-
RoomVersions.MSC3083,
235234
RoomVersions.V7,
236235
RoomVersions.MSC2716,
236+
RoomVersions.V8,
237237
)
238238
}
239239

synapse/event_auth.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,7 @@ def _is_membership_change_allowed(
370370
raise AuthError(403, "You are banned from this room")
371371
elif join_rule == JoinRules.PUBLIC:
372372
pass
373-
elif (
374-
room_version.msc3083_join_rules
375-
and join_rule == JoinRules.MSC3083_RESTRICTED
376-
):
373+
elif room_version.msc3083_join_rules and join_rule == JoinRules.RESTRICTED:
377374
# This is the same as public, but the event must contain a reference
378375
# to the server who authorised the join. If the event does not contain
379376
# the proper content it is rejected.

synapse/handlers/event_auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ async def has_restricted_join_rules(
240240

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

245245
async def get_rooms_that_allow_join(
246246
self, state_ids: StateMap[str]

tests/events/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def test_join_rules(self):
341341
"signatures": {},
342342
"unsigned": {},
343343
},
344-
room_version=RoomVersions.MSC3083,
344+
room_version=RoomVersions.V8,
345345
)
346346

347347

tests/handlers/test_space_summary.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,13 @@ def test_filtering(self):
231231
invited_room = self._create_room_with_join_rule(JoinRules.INVITE)
232232
self.helper.invite(invited_room, targ=user2, tok=self.token)
233233
restricted_room = self._create_room_with_join_rule(
234-
JoinRules.MSC3083_RESTRICTED,
235-
room_version=RoomVersions.MSC3083.identifier,
234+
JoinRules.RESTRICTED,
235+
room_version=RoomVersions.V8.identifier,
236236
allow=[],
237237
)
238238
restricted_accessible_room = self._create_room_with_join_rule(
239-
JoinRules.MSC3083_RESTRICTED,
240-
room_version=RoomVersions.MSC3083.identifier,
239+
JoinRules.RESTRICTED,
240+
room_version=RoomVersions.V8.identifier,
241241
allow=[
242242
{
243243
"type": RestrictedJoinRuleTypes.ROOM_MEMBERSHIP,
@@ -459,13 +459,13 @@ async def summarize_remote_room(
459459
{
460460
"room_id": restricted_room,
461461
"world_readable": False,
462-
"join_rules": JoinRules.MSC3083_RESTRICTED,
462+
"join_rules": JoinRules.RESTRICTED,
463463
"allowed_spaces": [],
464464
},
465465
{
466466
"room_id": restricted_accessible_room,
467467
"world_readable": False,
468-
"join_rules": JoinRules.MSC3083_RESTRICTED,
468+
"join_rules": JoinRules.RESTRICTED,
469469
"allowed_spaces": [self.room],
470470
},
471471
{

tests/test_event_auth.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ def test_join_rules_msc3083_restricted(self):
384384
},
385385
)
386386
event_auth.check(
387-
RoomVersions.MSC3083,
387+
RoomVersions.V8,
388388
authorised_join_event,
389389
auth_events,
390390
do_sig_check=False,
@@ -400,7 +400,7 @@ def test_join_rules_msc3083_restricted(self):
400400
"@inviter:foo.test"
401401
)
402402
event_auth.check(
403-
RoomVersions.MSC3083,
403+
RoomVersions.V8,
404404
_join_event(
405405
pleb,
406406
additional_content={
@@ -414,7 +414,7 @@ def test_join_rules_msc3083_restricted(self):
414414
# A join which is missing an authorised server is rejected.
415415
with self.assertRaises(AuthError):
416416
event_auth.check(
417-
RoomVersions.MSC3083,
417+
RoomVersions.V8,
418418
_join_event(pleb),
419419
auth_events,
420420
do_sig_check=False,
@@ -427,7 +427,7 @@ def test_join_rules_msc3083_restricted(self):
427427
)
428428
with self.assertRaises(AuthError):
429429
event_auth.check(
430-
RoomVersions.MSC3083,
430+
RoomVersions.V8,
431431
_join_event(
432432
pleb,
433433
additional_content={
@@ -442,7 +442,7 @@ def test_join_rules_msc3083_restricted(self):
442442
# *would* be valid, but is sent be a different user.)
443443
with self.assertRaises(AuthError):
444444
event_auth.check(
445-
RoomVersions.MSC3083,
445+
RoomVersions.V8,
446446
_member_event(
447447
pleb,
448448
"join",
@@ -459,7 +459,7 @@ def test_join_rules_msc3083_restricted(self):
459459
auth_events[("m.room.member", pleb)] = _member_event(pleb, "ban")
460460
with self.assertRaises(AuthError):
461461
event_auth.check(
462-
RoomVersions.MSC3083,
462+
RoomVersions.V8,
463463
authorised_join_event,
464464
auth_events,
465465
do_sig_check=False,
@@ -468,7 +468,7 @@ def test_join_rules_msc3083_restricted(self):
468468
# A user who left can re-join.
469469
auth_events[("m.room.member", pleb)] = _member_event(pleb, "leave")
470470
event_auth.check(
471-
RoomVersions.MSC3083,
471+
RoomVersions.V8,
472472
authorised_join_event,
473473
auth_events,
474474
do_sig_check=False,
@@ -478,7 +478,7 @@ def test_join_rules_msc3083_restricted(self):
478478
# be authorised since the user is already joined.)
479479
auth_events[("m.room.member", pleb)] = _member_event(pleb, "join")
480480
event_auth.check(
481-
RoomVersions.MSC3083,
481+
RoomVersions.V8,
482482
_join_event(pleb),
483483
auth_events,
484484
do_sig_check=False,
@@ -490,7 +490,7 @@ def test_join_rules_msc3083_restricted(self):
490490
pleb, "invite", sender=creator
491491
)
492492
event_auth.check(
493-
RoomVersions.MSC3083,
493+
RoomVersions.V8,
494494
_join_event(pleb),
495495
auth_events,
496496
do_sig_check=False,

0 commit comments

Comments
 (0)