From 641bac0ce5031c1a0edb1a61e674d429d3b3ee30 Mon Sep 17 00:00:00 2001 From: Till Faelligen <2353100+S7evinK@users.noreply.github.com> Date: Fri, 30 Jun 2023 14:32:46 +0200 Subject: [PATCH] Remove mxid_mapping before storing it in `unsigned.prev_content` --- syncapi/consumers/roomserver.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/syncapi/consumers/roomserver.go b/syncapi/consumers/roomserver.go index 35cc737bb..837ecc70b 100644 --- a/syncapi/consumers/roomserver.go +++ b/syncapi/consumers/roomserver.go @@ -21,11 +21,13 @@ import ( "fmt" "github.com/getsentry/sentry-go" + "github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/gomatrixserverlib/spec" "github.com/nats-io/nats.go" "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus" "github.com/tidwall/gjson" + "github.com/tidwall/sjson" "github.com/matrix-org/dendrite/internal/fulltext" "github.com/matrix-org/dendrite/internal/sqlutil" @@ -593,8 +595,17 @@ func (s *OutputRoomEventConsumer) updateStateEvent(event *rstypes.HeaderedEvent) return event, nil } + prevContent := prevEvent.Content() + // if we're storing a pseudoID event, make sure to delete the mxid_mapping + if event.Type() == spec.MRoomMember && event.Version() == gomatrixserverlib.RoomVersionPseudoIDs { + prevContent, err = sjson.DeleteBytes(prevEvent.Content(), "mxid_mapping") + if err != nil { + return event, err + } + } + prev := types.PrevEventRef{ - PrevContent: prevEvent.Content(), + PrevContent: prevContent, ReplacesState: prevEvent.EventID(), PrevSenderID: string(prevEvent.SenderID()), }