diff --git a/syncapi/storage/shared/syncserver.go b/syncapi/storage/shared/syncserver.go index 1d2fa12f..f11b00b3 100644 --- a/syncapi/storage/shared/syncserver.go +++ b/syncapi/storage/shared/syncserver.go @@ -675,7 +675,7 @@ func (d *Database) getResponseWithPDUsForCompleteSync( } // Add peeked rooms. - peeks, err := d.Peeks.SelectPeeks(ctx, userID, deviceID) + peeks, err := d.Peeks.SelectPeeks(ctx, txn, userID, deviceID) if err != nil { return } @@ -1012,7 +1012,7 @@ func (d *Database) getStateDeltas( // find out which rooms this user is peeking, if any. // We do this before joins so any peeks get overwritten - peeks, err := d.Peeks.SelectPeeks(ctx, userID, device.ID) + peeks, err := d.Peeks.SelectPeeks(ctx, txn, userID, device.ID) if err != nil { return nil, nil, err } @@ -1122,7 +1122,7 @@ func (d *Database) getStateDeltasForFullStateSync( return nil, nil, err } - peeks, err := d.Peeks.SelectPeeks(ctx, userID, device.ID) + peeks, err := d.Peeks.SelectPeeks(ctx, txn, userID, device.ID) if err != nil { return nil, nil, err } diff --git a/syncapi/storage/sqlite3/peeks_table.go b/syncapi/storage/sqlite3/peeks_table.go index 8fb74341..c013a635 100644 --- a/syncapi/storage/sqlite3/peeks_table.go +++ b/syncapi/storage/sqlite3/peeks_table.go @@ -136,9 +136,9 @@ func (s *peekStatements) DeletePeeks( } func (s *peekStatements) SelectPeeks( - ctx context.Context, userID, deviceID string, + ctx context.Context, txn *sql.Tx, userID, deviceID string, ) (peeks []types.Peek, err error) { - rows, err := s.selectPeeksStmt.QueryContext(ctx, userID, deviceID) + rows, err := sqlutil.TxStmt(txn, s.selectPeeksStmt).QueryContext(ctx, userID, deviceID) if err != nil { return } diff --git a/syncapi/storage/tables/interface.go b/syncapi/storage/tables/interface.go index 3ca374e4..1f8663b9 100644 --- a/syncapi/storage/tables/interface.go +++ b/syncapi/storage/tables/interface.go @@ -43,7 +43,7 @@ type Peeks interface { InsertPeek(ctx context.Context, txn *sql.Tx, roomID, userID, deviceID string) (streamPos types.StreamPosition, err error) DeletePeek(ctx context.Context, txn *sql.Tx, roomID, userID, deviceID string) (streamPos types.StreamPosition, err error) DeletePeeks(ctx context.Context, txn *sql.Tx, roomID, userID string) (streamPos types.StreamPosition, err error) - SelectPeeks(ctxt context.Context, userID, deviceID string) (peeks []types.Peek, err error) + SelectPeeks(ctxt context.Context, txn *sql.Tx, userID, deviceID string) (peeks []types.Peek, err error) SelectPeekingDevices(ctxt context.Context) (peekingDevices map[string][]types.PeekingDevice, err error) MarkPeeksAsOld(ctxt context.Context, txn *sql.Tx, userID, deviceID string) (err error) }