big ole refactor

This commit is contained in:
2026-02-14 19:48:59 +11:00
parent 0fc3bb0c94
commit 4a2396bca8
66 changed files with 989 additions and 1114 deletions

View File

@@ -20,7 +20,7 @@ import (
func Register(
s *hws.Server,
auth *hwsauth.Authenticator[*db.User, bun.Tx],
conn *bun.DB,
conn *db.DB,
cfg *config.Config,
store *store.Store,
) http.Handler {
@@ -55,7 +55,7 @@ func Register(
username := r.FormValue("username")
unique := false
var user *db.User
if ok := db.WithNotifyTx(s, w, r, conn, func(ctx context.Context, tx bun.Tx) (bool, error) {
if ok := conn.WithNotifyTx(s, w, r, func(ctx context.Context, tx bun.Tx) (bool, error) {
unique, err = db.IsUnique(ctx, tx, (*db.User)(nil), "username", username)
if err != nil {
return false, errors.Wrap(err, "db.IsUsernameUnique")
@@ -63,7 +63,7 @@ func Register(
if !unique {
return true, nil
}
user, err = db.CreateUser(ctx, tx, username, details.DiscordUser)
user, err = db.CreateUser(ctx, tx, username, details.DiscordUser, db.NewAudit(r, nil))
if err != nil {
return false, errors.Wrap(err, "db.CreateUser")
}