mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-02 06:12:45 +00:00
Merge Updater structs (#1069)
* Move Updater structs to shared and use it for postgres * Add constructors for NewXXXUpdater and a useTxns flag In sqlite, we set useTxns=false and comment why. * Handle nil txn * Handle nil in transaction * Missed one * Close the txn at the right time * Don't close the transaction as we reuse it between calls
This commit is contained in:
parent
02fe38e1f7
commit
a6f995eb45
8 changed files with 381 additions and 744 deletions
|
@ -90,7 +90,6 @@ func (s *inviteStatements) InsertInviteEvent(
|
|||
inviteEventJSON []byte,
|
||||
) (bool, error) {
|
||||
stmt := internal.TxStmt(txn, s.insertInviteEventStmt)
|
||||
defer stmt.Close() // nolint: errcheck
|
||||
result, err := stmt.ExecContext(
|
||||
ctx, inviteEventID, roomNID, targetUserNID, senderUserNID, inviteEventJSON,
|
||||
)
|
||||
|
@ -109,7 +108,7 @@ func (s *inviteStatements) UpdateInviteRetired(
|
|||
txn *sql.Tx, roomNID types.RoomNID, targetUserNID types.EventStateKeyNID,
|
||||
) (eventIDs []string, err error) {
|
||||
// gather all the event IDs we will retire
|
||||
stmt := txn.Stmt(s.selectInvitesAboutToRetireStmt)
|
||||
stmt := internal.TxStmt(txn, s.selectInvitesAboutToRetireStmt)
|
||||
rows, err := stmt.QueryContext(ctx, roomNID, targetUserNID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -124,7 +123,7 @@ func (s *inviteStatements) UpdateInviteRetired(
|
|||
}
|
||||
|
||||
// now retire the invites
|
||||
stmt = txn.Stmt(s.updateInviteRetiredStmt)
|
||||
stmt = internal.TxStmt(txn, s.updateInviteRetiredStmt)
|
||||
_, err = stmt.ExecContext(ctx, roomNID, targetUserNID)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue