use servemux *properly* this time; better error handling for DB gets

This commit is contained in:
ari melody 2025-11-08 15:04:07 +00:00
parent a33e6717e0
commit b7c1d85830
Signed by: ari
GPG key ID: CF99829C92678188
16 changed files with 234 additions and 288 deletions

View file

@ -16,9 +16,7 @@ func GetInvite(db *sqlx.DB, code string) (*model.Invite, error) {
err := db.Get(&invite, "SELECT * FROM invite WHERE code=$1", code)
if err != nil {
if strings.Contains(err.Error(), "no rows") {
return nil, nil
}
if strings.Contains(err.Error(), "no rows") { return nil, nil }
return nil, err
}
@ -32,7 +30,7 @@ func CreateInvite(db *sqlx.DB, length int, lifetime time.Duration) (*model.Invit
}
code := []byte{}
for i := 0; i < length; i++ {
for range length {
code = append(code, inviteChars[rand.Intn(len(inviteChars) - 1)])
}
invite.Code = string(code)