Remove mxid_mapping before storing it in unsigned.prev_content

This commit is contained in:
Till Faelligen 2023-06-30 14:32:46 +02:00
parent 552eaf2940
commit 641bac0ce5
No known key found for this signature in database
GPG key ID: ACCDC9606D472758

View file

@ -21,11 +21,13 @@ import (
"fmt" "fmt"
"github.com/getsentry/sentry-go" "github.com/getsentry/sentry-go"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/gomatrixserverlib/spec" "github.com/matrix-org/gomatrixserverlib/spec"
"github.com/nats-io/nats.go" "github.com/nats-io/nats.go"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/tidwall/gjson" "github.com/tidwall/gjson"
"github.com/tidwall/sjson"
"github.com/matrix-org/dendrite/internal/fulltext" "github.com/matrix-org/dendrite/internal/fulltext"
"github.com/matrix-org/dendrite/internal/sqlutil" "github.com/matrix-org/dendrite/internal/sqlutil"
@ -593,8 +595,17 @@ func (s *OutputRoomEventConsumer) updateStateEvent(event *rstypes.HeaderedEvent)
return event, nil 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{ prev := types.PrevEventRef{
PrevContent: prevEvent.Content(), PrevContent: prevContent,
ReplacesState: prevEvent.EventID(), ReplacesState: prevEvent.EventID(),
PrevSenderID: string(prevEvent.SenderID()), PrevSenderID: string(prevEvent.SenderID()),
} }