From 61c67722b3f097f9d9e715e80dc94e24313c6ac9 Mon Sep 17 00:00:00 2001 From: Till Faelligen <2353100+S7evinK@users.noreply.github.com> Date: Wed, 8 Mar 2023 11:43:09 +0100 Subject: [PATCH] Set redacted when parsing the event, since we already store the redacted event in the database --- roomserver/storage/shared/storage.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/roomserver/storage/shared/storage.go b/roomserver/storage/shared/storage.go index 0ccd49115..0cf598ef0 100644 --- a/roomserver/storage/shared/storage.go +++ b/roomserver/storage/shared/storage.go @@ -564,9 +564,10 @@ func (d *EventDatabase) events( Event: event, }) } - if !redactionsArePermanent { + if redactionsArePermanent { d.applyRedactions(results) } + return results, nil } eventJSONs, err := d.EventJSONTable.BulkSelectEventJSON(ctx, txn, eventNIDs) if err != nil { @@ -578,8 +579,9 @@ func (d *EventDatabase) events( } for _, eventJSON := range eventJSONs { + redacted := gjson.GetBytes(eventJSON.EventJSON, "unsigned.redacted_because").Exists() events[eventJSON.EventNID], err = gomatrixserverlib.NewEventFromTrustedJSONWithEventID( - eventIDs[eventJSON.EventNID], eventJSON.EventJSON, false, roomInfo.RoomVersion, + eventIDs[eventJSON.EventNID], eventJSON.EventJSON, redacted, roomInfo.RoomVersion, ) if err != nil { return nil, err @@ -599,7 +601,7 @@ func (d *EventDatabase) events( Event: event, }) } - if !redactionsArePermanent { + if redactionsArePermanent { d.applyRedactions(results) } return results, nil