re-add txn to SelectPeeks

This commit is contained in:
Matthew Hodgson 2020-09-02 10:07:49 +01:00
parent 75b91ac9e5
commit b6cc4417cc
3 changed files with 6 additions and 6 deletions

View file

@ -675,7 +675,7 @@ func (d *Database) getResponseWithPDUsForCompleteSync(
} }
// Add peeked rooms. // Add peeked rooms.
peeks, err := d.Peeks.SelectPeeks(ctx, userID, deviceID) peeks, err := d.Peeks.SelectPeeks(ctx, txn, userID, deviceID)
if err != nil { if err != nil {
return return
} }
@ -1012,7 +1012,7 @@ func (d *Database) getStateDeltas(
// find out which rooms this user is peeking, if any. // find out which rooms this user is peeking, if any.
// We do this before joins so any peeks get overwritten // 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 { if err != nil {
return nil, nil, err return nil, nil, err
} }
@ -1122,7 +1122,7 @@ func (d *Database) getStateDeltasForFullStateSync(
return nil, nil, err 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 { if err != nil {
return nil, nil, err return nil, nil, err
} }

View file

@ -136,9 +136,9 @@ func (s *peekStatements) DeletePeeks(
} }
func (s *peekStatements) SelectPeeks( func (s *peekStatements) SelectPeeks(
ctx context.Context, userID, deviceID string, ctx context.Context, txn *sql.Tx, userID, deviceID string,
) (peeks []types.Peek, err error) { ) (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 { if err != nil {
return return
} }

View file

@ -43,7 +43,7 @@ type Peeks interface {
InsertPeek(ctx context.Context, txn *sql.Tx, roomID, userID, deviceID string) (streamPos types.StreamPosition, err error) 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) 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) 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) SelectPeekingDevices(ctxt context.Context) (peekingDevices map[string][]types.PeekingDevice, err error)
MarkPeeksAsOld(ctxt context.Context, txn *sql.Tx, userID, deviceID string) (err error) MarkPeeksAsOld(ctxt context.Context, txn *sql.Tx, userID, deviceID string) (err error)
} }