summary refs log tree commit diff
path: root/synapse/events/utils.py
diff options
context:
space:
mode:
authorPatrick Cloke <clokep@users.noreply.github.com>2023-05-15 15:02:24 -0400
committerGitHub <noreply@github.com>2023-05-15 15:02:24 -0400
commitf2905d827f8e5360907dadfd205da588f92aa286 (patch)
tree04bd35a8126b8ace2465d9db41d6b5711970744a /synapse/events/utils.py
parentReject instead of erroring on invalid membership events. (#15564) (diff)
downloadsynapse-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/utils.py')
-rw-r--r--synapse/events/utils.py10
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: