diff options
author | Shay <hillerys@element.io> | 2023-07-23 16:32:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-23 16:32:01 -0700 |
commit | 5c7364fea57e24ae3ce2ac833a3521abd58312db (patch) | |
tree | 2df6dd437d8c6f978569b50ad0fa01f0074c076c | |
parent | Actually stop reading from column `user_id` of tables `profiles` (#15955) (diff) | |
download | synapse-5c7364fea57e24ae3ce2ac833a3521abd58312db.tar.xz |
Properly handle redactions of creation events (#15973)
-rw-r--r-- | changelog.d/15973.bugfix | 1 | ||||
-rw-r--r-- | synapse/events/utils.py | 8 | ||||
-rw-r--r-- | tests/events/test_utils.py | 9 |
3 files changed, 13 insertions, 5 deletions
diff --git a/changelog.d/15973.bugfix b/changelog.d/15973.bugfix new file mode 100644 index 0000000000..c9280d0037 --- /dev/null +++ b/changelog.d/15973.bugfix @@ -0,0 +1 @@ +Properly handle redactions of creation events. diff --git a/synapse/events/utils.py b/synapse/events/utils.py index ecfc5c0568..c890833b1d 100644 --- a/synapse/events/utils.py +++ b/synapse/events/utils.py @@ -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: diff --git a/tests/events/test_utils.py b/tests/events/test_utils.py index 6a52af4d82..978612e432 100644 --- a/tests/events/test_utils.py +++ b/tests/events/test_utils.py @@ -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}, |