From 9172814e1ea2d296c52fad662da20e07c6f180b4 Mon Sep 17 00:00:00 2001 From: Till Faelligen <2353100+S7evinK@users.noreply.github.com> Date: Fri, 22 Sep 2023 15:29:46 +0200 Subject: [PATCH] Move "redacts" to "content.redacts" --- syncapi/synctypes/clientevent.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/syncapi/synctypes/clientevent.go b/syncapi/synctypes/clientevent.go index 6812f8332..45aa192ac 100644 --- a/syncapi/synctypes/clientevent.go +++ b/syncapi/synctypes/clientevent.go @@ -141,6 +141,18 @@ func ToClientEvent(se gomatrixserverlib.PDU, format ClientEventFormat, userIDFor 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 { case FormatAll: ce.RoomID = se.RoomID().String()