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

Commit 54651f0

Browse files
H-ShayFizzadar
authored andcommitted
Properly handle redactions of creation events (matrix-org#15973)
1 parent cdbe9e1 commit 54651f0

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

changelog.d/15973.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Properly handle redactions of creation events.

synapse/events/utils.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,13 @@ def add_fields(*fields: str) -> None:
136136
]
137137

138138
elif event_type == EventTypes.Create:
139-
# MSC2176 rules state that create events cannot be redacted.
140139
if room_version.updated_redaction_rules:
141-
return event_dict
140+
# MSC2176 rules state that create events cannot have their `content` redacted.
141+
new_content = event_dict["content"]
142+
elif not room_version.implicit_room_creator:
143+
# Some room versions give meaning to `creator`
144+
add_fields("creator")
142145

143-
add_fields("creator")
144146
elif event_type == EventTypes.JoinRules:
145147
add_fields("join_rule")
146148
if room_version.restricted_join_rule:

tests/events/test_utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,14 @@ def test_create(self) -> None:
225225
},
226226
)
227227

228-
# After MSC2176, create events get nothing redacted.
228+
# After MSC2176, create events should preserve field `content`
229229
self.run_test(
230-
{"type": "m.room.create", "content": {"not_a_real_key": True}},
230+
{
231+
"type": "m.room.create",
232+
"content": {"not_a_real_key": True},
233+
"origin": "some_homeserver",
234+
"nonsense_field": "some_random_garbage",
235+
},
231236
{
232237
"type": "m.room.create",
233238
"content": {"not_a_real_key": True},

0 commit comments

Comments
 (0)