-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Implement MSC2176: Updated redaction rules #8984
Changes from 5 commits
32e3692
8893bd6
2d09478
402aabb
f8f5b03
1f35bb9
8ae3273
479f333
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Implement [MSC2176](https://github.com/matrix-org/matrix-doc/pull/2176) in an experimental room version. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,13 +79,15 @@ def prune_event_dict(room_version: RoomVersion, event_dict: dict) -> dict: | |
"state_key", | ||
"depth", | ||
"prev_events", | ||
"prev_state", | ||
"auth_events", | ||
"origin", | ||
"origin_server_ts", | ||
"membership", | ||
] | ||
|
||
# Room versions from before MSC 2176 had additional allowed keys. | ||
clokep marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if not room_version.msc2176_redaction_rules: | ||
allowed_keys.extend(["prev_state", "membership"]) | ||
|
||
event_type = event_dict["type"] | ||
|
||
new_content = {} | ||
|
@@ -98,6 +100,10 @@ def add_fields(*fields): | |
if event_type == EventTypes.Member: | ||
add_fields("membership") | ||
elif event_type == EventTypes.Create: | ||
# MSC 2176 rules state that create events cannot be redacted. | ||
if room_version.msc2176_redaction_rules: | ||
return event_dict | ||
|
||
add_fields("creator") | ||
elif event_type == EventTypes.JoinRules: | ||
add_fields("join_rule") | ||
|
@@ -112,10 +118,16 @@ def add_fields(*fields): | |
"kick", | ||
"redact", | ||
) | ||
|
||
if room_version.msc2176_redaction_rules: | ||
add_fields("invite") | ||
|
||
elif event_type == EventTypes.Aliases and room_version.special_case_aliases_auth: | ||
add_fields("aliases") | ||
elif event_type == EventTypes.RoomHistoryVisibility: | ||
add_fields("history_visibility") | ||
elif event_type == EventTypes.Redaction and room_version.msc2176_redaction_rules: | ||
add_fields("redacts") | ||
Comment on lines
+129
to
+130
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that this is really matrix-org/matrix-spec-proposals#2174. I suspect further changes are needed to support this although I'm not 100% sure what. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only odd thing about this is that currently a redaction event doesn't have the redacts keyword, so I think this will generally raise an exception. (Note that the tests somewhat skip this by manually creating an event that does have the proper keyword.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure MSC2174 actually requires this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
allowed_fields = {k: v for k, v in event_dict.items() if k in allowed_keys} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.