mirror of
https://github.com/J3vb/OwnCord.git
synced 2026-09-03 03:50:00 +03:00
- Atomic CreateUserWithInvite prevents invite burn on failed registration - Channel search fails closed on channel-type and override lookup errors - Malformed FTS input returns 400 instead of 500 - Search rate limiting uses own namespace, respects trusted proxy IPs - Login lockout keyed by forwarded client IP behind reverse proxy - Trusted same-server OG previews re-enabled with self-signed cert support - Normalized host matching for embeds/attachments - Regression tests for all changes (auth, channel, embeds)
34 lines
1.1 KiB
Go
34 lines
1.1 KiB
Go
package db
|
|
|
|
import (
|
|
"errors"
|
|
"strings"
|
|
)
|
|
|
|
// Sentinel errors for the db package. Use errors.Is() to check.
|
|
var (
|
|
// ErrNotFound indicates the requested resource does not exist.
|
|
ErrNotFound = errors.New("not found")
|
|
|
|
// ErrForbidden indicates the caller lacks permission for the operation.
|
|
ErrForbidden = errors.New("forbidden")
|
|
|
|
// ErrConflict indicates a uniqueness constraint violation (e.g., duplicate username).
|
|
ErrConflict = errors.New("conflict")
|
|
|
|
// ErrBanned indicates the user is banned.
|
|
ErrBanned = errors.New("banned")
|
|
|
|
// ErrLastAdmin indicates the operation was rejected because the user is
|
|
// the only remaining admin/owner and deleting them would leave the server
|
|
// without an administrator.
|
|
ErrLastAdmin = errors.New("last admin cannot be deleted")
|
|
)
|
|
|
|
// IsUniqueConstraintError reports whether err is a SQLite UNIQUE constraint
|
|
// violation. This centralizes the fragile string check so callers don't
|
|
// scatter strings.Contains calls throughout the codebase.
|
|
func IsUniqueConstraintError(err error) bool {
|
|
return err != nil && strings.Contains(err.Error(), "UNIQUE constraint")
|
|
}
|