Use db.WithTx/WithTx2 instead of TxContext when possible (#35130)

This commit is contained in:
Lunny Xiao
2025-07-23 01:02:01 +08:00
committed by GitHub
parent f201dde945
commit 65cd3f5309
56 changed files with 1999 additions and 2640 deletions

View File

@@ -224,21 +224,9 @@ func CreateReaction(ctx context.Context, opts *ReactionOptions) (*Reaction, erro
return nil, ErrForbiddenIssueReaction{opts.Type}
}
ctx, committer, err := db.TxContext(ctx)
if err != nil {
return nil, err
}
defer committer.Close()
reaction, err := createReaction(ctx, opts)
if err != nil {
return reaction, err
}
if err := committer.Commit(); err != nil {
return nil, err
}
return reaction, nil
return db.WithTx2(ctx, func(ctx context.Context) (*Reaction, error) {
return createReaction(ctx, opts)
})
}
// DeleteReaction deletes reaction for issue or comment.