Handle redactions

This commit is contained in:
Neil Alexander 2022-10-11 14:17:51 +01:00
parent ff786c0094
commit c9ef9a6106
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -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
})
}