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

Commit 752fe0c

Browse files
authored
Restricted rooms (MSC3083) should not have their allow key redacted. (#10489)
1 parent c3b0377 commit 752fe0c

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

changelog.d/10489.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update support for [MSC3083](https://github.com/matrix-org/matrix-doc/pull/3083) to consider changes in the MSC around which servers can issue join events.

synapse/events/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ def add_fields(*fields):
109109
add_fields("creator")
110110
elif event_type == EventTypes.JoinRules:
111111
add_fields("join_rule")
112+
if room_version.msc3083_join_rules:
113+
add_fields("allow")
112114
elif event_type == EventTypes.PowerLevels:
113115
add_fields(
114116
"users",

tests/events/test_utils.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,49 @@ def test_redacts(self):
301301
room_version=RoomVersions.MSC2176,
302302
)
303303

304+
def test_join_rules(self):
305+
"""Join rules events have changed behavior starting with MSC3083."""
306+
self.run_test(
307+
{
308+
"type": "m.room.join_rules",
309+
"event_id": "$test:domain",
310+
"content": {
311+
"join_rule": "invite",
312+
"allow": [],
313+
"other_key": "stripped",
314+
},
315+
},
316+
{
317+
"type": "m.room.join_rules",
318+
"event_id": "$test:domain",
319+
"content": {"join_rule": "invite"},
320+
"signatures": {},
321+
"unsigned": {},
322+
},
323+
)
324+
325+
# After MSC3083, alias events have no special behavior.
326+
self.run_test(
327+
{
328+
"type": "m.room.join_rules",
329+
"content": {
330+
"join_rule": "invite",
331+
"allow": [],
332+
"other_key": "stripped",
333+
},
334+
},
335+
{
336+
"type": "m.room.join_rules",
337+
"content": {
338+
"join_rule": "invite",
339+
"allow": [],
340+
},
341+
"signatures": {},
342+
"unsigned": {},
343+
},
344+
room_version=RoomVersions.MSC3083,
345+
)
346+
304347

305348
class SerializeEventTestCase(unittest.TestCase):
306349
def serialize(self, ev, fields):

0 commit comments

Comments
 (0)