diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2023-05-15 15:02:24 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-15 15:02:24 -0400 |
commit | f2905d827f8e5360907dadfd205da588f92aa286 (patch) | |
tree | 04bd35a8126b8ace2465d9db41d6b5711970744a /synapse/events | |
parent | Reject instead of erroring on invalid membership events. (#15564) (diff) | |
download | synapse-f2905d827f8e5360907dadfd205da588f92aa286.tar.xz |
Implement MSC3821 to update redaction rules (`third_party_invite.signed`) (#15563)
Updates the redaction rules to protect enough information that the event can still be properly verified.
Diffstat (limited to 'synapse/events')
-rw-r--r-- | synapse/events/utils.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/synapse/events/utils.py b/synapse/events/utils.py index e540f1582a..e6d040176b 100644 --- a/synapse/events/utils.py +++ b/synapse/events/utils.py @@ -130,6 +130,16 @@ def prune_event_dict(room_version: RoomVersion, event_dict: JsonDict) -> JsonDic add_fields("membership") if room_version.msc3375_redaction_rules: add_fields(EventContentFields.AUTHORISING_USER) + if room_version.msc3821_redaction_rules: + # Preserve the signed field under third_party_invite. + third_party_invite = event_dict["content"].get("third_party_invite") + if isinstance(third_party_invite, collections.abc.Mapping): + new_content["third_party_invite"] = {} + if "signed" in third_party_invite: + new_content["third_party_invite"]["signed"] = third_party_invite[ + "signed" + ] + elif event_type == EventTypes.Create: # MSC2176 rules state that create events cannot be redacted. if room_version.msc2176_redaction_rules: |