Move "redacts" to "content.redacts"

This commit is contained in:
Till Faelligen 2023-09-22 15:29:46 +02:00
parent db83789654
commit 9172814e1e
No known key found for this signature in database
GPG key ID: ACCDC9606D472758

View file

@ -141,6 +141,18 @@ func ToClientEvent(se gomatrixserverlib.PDU, format ClientEventFormat, userIDFor
Redacts: se.Redacts(), Redacts: se.Redacts(),
} }
// RoomVersion V11 moved the "redacts" field to "content", so add it there as well
// For compatibility with older clients, we keep the "redacts" top-level field.
// TODO: At which point do we remove "redacts" from the top-level?
if se.Type() == spec.MRoomRedaction && se.Version() == gomatrixserverlib.RoomVersionV11 && ce.Redacts != "" {
v11content, err := sjson.SetBytes(ce.Content, "content.redacts", ce.Redacts)
if err != nil {
logrus.WithError(err).Warn("failed to set content.redacts")
} else {
ce.Content = v11content
}
}
switch format { switch format {
case FormatAll: case FormatAll:
ce.RoomID = se.RoomID().String() ce.RoomID = se.RoomID().String()