diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2023-08-02 11:35:54 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-02 15:35:54 +0000 |
commit | 4f5bccbbba13ba10412497cb92a1460535cf7a25 (patch) | |
tree | a59b26b5f3345841f965235d53d70f78e0e6eae0 /synapse/events/utils.py | |
parent | Update MSC3958 support to interact with intentional mentions. (#15992) (diff) | |
download | synapse-4f5bccbbba13ba10412497cb92a1460535cf7a25.tar.xz |
Add forward-compatibility for the redacts property (MSC2174). (#16013)
The location of the redacts field changes in room version 11. Ensure it is copied to the *new* location for *old* room versions for forwards-compatibility with clients. Note that copying it to the *old* location for the *new* room version was previously handled.
Diffstat (limited to 'synapse/events/utils.py')
-rw-r--r-- | synapse/events/utils.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/synapse/events/utils.py b/synapse/events/utils.py index c890833b1d..967a6c245b 100644 --- a/synapse/events/utils.py +++ b/synapse/events/utils.py @@ -475,14 +475,16 @@ def serialize_event( if config.as_client_event: d = config.event_format(d) - # If the event is a redaction, copy the redacts field from the content to - # top-level for backwards compatibility. - if ( - e.type == EventTypes.Redaction - and e.room_version.updated_redaction_rules - and e.redacts is not None - ): - d["redacts"] = e.redacts + # If the event is a redaction, the field with the redacted event ID appears + # in a different location depending on the room version. e.redacts handles + # fetching from the proper location; copy it to the other location for forwards- + # and backwards-compatibility with clients. + if e.type == EventTypes.Redaction and e.redacts is not None: + if e.room_version.updated_redaction_rules: + d["redacts"] = e.redacts + else: + d["content"] = dict(d["content"]) + d["content"]["redacts"] = e.redacts only_event_fields = config.only_event_fields if only_event_fields: |