Set redacted when parsing the event, since we already store the redacted

event in the database
This commit is contained in:
Till Faelligen 2023-03-08 11:43:09 +01:00
parent d95b0cd1ae
commit 61c67722b3
No known key found for this signature in database
GPG key ID: ACCDC9606D472758

View file

@ -564,9 +564,10 @@ func (d *EventDatabase) events(
Event: event, Event: event,
}) })
} }
if !redactionsArePermanent { if redactionsArePermanent {
d.applyRedactions(results) d.applyRedactions(results)
} }
return results, nil
} }
eventJSONs, err := d.EventJSONTable.BulkSelectEventJSON(ctx, txn, eventNIDs) eventJSONs, err := d.EventJSONTable.BulkSelectEventJSON(ctx, txn, eventNIDs)
if err != nil { if err != nil {
@ -578,8 +579,9 @@ func (d *EventDatabase) events(
} }
for _, eventJSON := range eventJSONs { for _, eventJSON := range eventJSONs {
redacted := gjson.GetBytes(eventJSON.EventJSON, "unsigned.redacted_because").Exists()
events[eventJSON.EventNID], err = gomatrixserverlib.NewEventFromTrustedJSONWithEventID( 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 { if err != nil {
return nil, err return nil, err
@ -599,7 +601,7 @@ func (d *EventDatabase) events(
Event: event, Event: event,
}) })
} }
if !redactionsArePermanent { if redactionsArePermanent {
d.applyRedactions(results) d.applyRedactions(results)
} }
return results, nil return results, nil