mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 10:33:11 -06:00
Update deletion/redaction
This commit is contained in:
parent
c9ef9a6106
commit
1f06794904
|
|
@ -46,7 +46,7 @@ const insertRelationSQL = "" +
|
|||
" RETURNING id"
|
||||
|
||||
const deleteRelationSQL = "" +
|
||||
"DELETE FROM syncapi_relations WHERE event_id = $1"
|
||||
"DELETE FROM syncapi_relations WHERE room_id = $1 AND child_event_id = $2"
|
||||
|
||||
const selectRelationsInRangeSQL = "" +
|
||||
"SELECT id, room_id, child_event_id, rel_type FROM syncapi_relations" +
|
||||
|
|
@ -103,11 +103,11 @@ func (s *relationsStatements) InsertRelation(
|
|||
}
|
||||
|
||||
func (s *relationsStatements) DeleteRelation(
|
||||
ctx context.Context, txn *sql.Tx, roomID, eventID, childEventID, relType string,
|
||||
ctx context.Context, txn *sql.Tx, roomID, childEventID string,
|
||||
) error {
|
||||
stmt := sqlutil.TxStmt(txn, s.deleteRelationStmt)
|
||||
_, err := stmt.ExecContext(
|
||||
ctx, roomID, eventID, childEventID, relType,
|
||||
ctx, roomID, childEventID,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -598,10 +598,9 @@ func (d *Database) UpdateRelations(ctx context.Context, event *gomatrixserverlib
|
|||
}
|
||||
return d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
|
||||
var err error
|
||||
if event.Redacted() {
|
||||
if event.Type() == gomatrixserverlib.MRoomRedaction {
|
||||
err = d.Relations.DeleteRelation(
|
||||
ctx, txn, event.RoomID(), content.Relations.EventID,
|
||||
event.EventID(), content.Relations.RelationType,
|
||||
ctx, txn, event.RoomID(), event.Redacts(),
|
||||
)
|
||||
} else {
|
||||
_, err = d.Relations.InsertRelation(
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ type Presence interface {
|
|||
|
||||
type Relations interface {
|
||||
InsertRelation(ctx context.Context, txn *sql.Tx, roomID, eventID, childEventID, relType string) (streamPos types.StreamPosition, err error)
|
||||
DeleteRelation(ctx context.Context, txn *sql.Tx, roomID, eventID, childEventID, relType string) error
|
||||
DeleteRelation(ctx context.Context, txn *sql.Tx, roomID, childEventID string) error
|
||||
SelectRelationsInRange(ctx context.Context, txn *sql.Tx, roomID, eventID, relType string, r types.Range) (map[string][]string, types.StreamPosition, error)
|
||||
SelectMaxRelationID(ctx context.Context, txn *sql.Tx) (id int64, err error)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue