From c9ef9a61062d92353067deffdf08f7db2dac51fe Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Tue, 11 Oct 2022 14:17:51 +0100 Subject: [PATCH] Handle redactions --- syncapi/storage/shared/storage_consumer.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/syncapi/storage/shared/storage_consumer.go b/syncapi/storage/shared/storage_consumer.go index e8f9c4946..f921db4b4 100644 --- a/syncapi/storage/shared/storage_consumer.go +++ b/syncapi/storage/shared/storage_consumer.go @@ -597,10 +597,18 @@ func (d *Database) UpdateRelations(ctx context.Context, event *gomatrixserverlib return nil } return d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error { - _, err := d.Relations.InsertRelation( - ctx, txn, event.RoomID(), content.Relations.EventID, - event.EventID(), content.Relations.RelationType, - ) + var err error + if event.Redacted() { + err = d.Relations.DeleteRelation( + ctx, txn, event.RoomID(), content.Relations.EventID, + event.EventID(), content.Relations.RelationType, + ) + } else { + _, err = d.Relations.InsertRelation( + ctx, txn, event.RoomID(), content.Relations.EventID, + event.EventID(), content.Relations.RelationType, + ) + } return err }) }