mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-13 11:33:25 +01:00
Properly handle redactions of creation events (#15973)
This commit is contained in:
parent
f08d05dd2c
commit
5c7364fea5
3 changed files with 13 additions and 5 deletions
1
changelog.d/15973.bugfix
Normal file
1
changelog.d/15973.bugfix
Normal file
|
@ -0,0 +1 @@
|
|||
Properly handle redactions of creation events.
|
|
@ -136,11 +136,13 @@ def prune_event_dict(room_version: RoomVersion, event_dict: JsonDict) -> JsonDic
|
|||
]
|
||||
|
||||
elif event_type == EventTypes.Create:
|
||||
# MSC2176 rules state that create events cannot be redacted.
|
||||
if room_version.updated_redaction_rules:
|
||||
return event_dict
|
||||
# MSC2176 rules state that create events cannot have their `content` redacted.
|
||||
new_content = event_dict["content"]
|
||||
elif not room_version.implicit_room_creator:
|
||||
# Some room versions give meaning to `creator`
|
||||
add_fields("creator")
|
||||
|
||||
add_fields("creator")
|
||||
elif event_type == EventTypes.JoinRules:
|
||||
add_fields("join_rule")
|
||||
if room_version.restricted_join_rule:
|
||||
|
|
|
@ -225,9 +225,14 @@ class PruneEventTestCase(stdlib_unittest.TestCase):
|
|||
},
|
||||
)
|
||||
|
||||
# After MSC2176, create events get nothing redacted.
|
||||
# After MSC2176, create events should preserve field `content`
|
||||
self.run_test(
|
||||
{"type": "m.room.create", "content": {"not_a_real_key": True}},
|
||||
{
|
||||
"type": "m.room.create",
|
||||
"content": {"not_a_real_key": True},
|
||||
"origin": "some_homeserver",
|
||||
"nonsense_field": "some_random_garbage",
|
||||
},
|
||||
{
|
||||
"type": "m.room.create",
|
||||
"content": {"not_a_real_key": True},
|
||||
|
|
Loading…
Reference in a new issue