mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
start working on struct validation for gtsmodel
This commit is contained in:
@@ -26,97 +26,45 @@ import (
|
||||
// User represents an actual human user of gotosocial. Note, this is a LOCAL gotosocial user, not a remote account.
|
||||
// To cross reference this local user with their account (which can be local or remote), use the AccountID field.
|
||||
type User struct {
|
||||
/*
|
||||
BASIC INFO
|
||||
*/
|
||||
ID string `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"` // id of this item in the database
|
||||
CreatedAt time.Time `validate:"required" bun:",nullzero,notnull,default:current_timestamp"` // when was item created
|
||||
UpdatedAt time.Time `validate:"required" bun:",nullzero,notnull,default:current_timestamp"` // when was item last updated
|
||||
Email string `validate:"required_with=ConfirmedAt" bun:",nullzero,notnull,unique"` // confirmed email address for this user, this should be unique -- only one email address registered per instance, multiple users per email are not supported
|
||||
AccountID string `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull,unique"` // The id of the local gtsmodel.Account entry for this user.
|
||||
Account *Account `validate:"-" bun:"rel:belongs-to"` // Pointer to the account of this user that corresponds to AccountID.
|
||||
EncryptedPassword string `validate:"required" bun:",nullzero,notnull"` // The encrypted password of this user, generated using https://pkg.go.dev/golang.org/x/crypto/bcrypt#GenerateFromPassword. A salt is included so we're safe against 🌈 tables.
|
||||
SignUpIP net.IP `validate:"-" bun:",nullzero"` // From what IP was this user created?
|
||||
CurrentSignInAt time.Time `validate:"-" bun:",nullzero"` // When did the user sign in with their current session.
|
||||
CurrentSignInIP net.IP `validate:"-" bun:",nullzero"` // What's the most recent IP of this user
|
||||
LastSignInAt time.Time `validate:"-" bun:",nullzero"` // When did this user last sign in?
|
||||
LastSignInIP net.IP `validate:"-" bun:",nullzero"` // What's the previous IP of this user?
|
||||
SignInCount int `validate:"-" bun:",nullzero,notnull,default:0"` // How many times has this user signed in?
|
||||
InviteID string `validate:"ulid" bun:"type:CHAR(26),nullzero"` // id of the user who invited this user (who let this joker in?)
|
||||
ChosenLanguages []string `validate:"-" bun:",nullzero"` // What languages does this user want to see?
|
||||
FilteredLanguages []string `validate:"-" bun:",nullzero"` // What languages does this user not want to see?
|
||||
Locale string `validate:"-" bun:",nullzero"` // In what timezone/locale is this user located?
|
||||
CreatedByApplicationID string `validate:"ulid" bun:"type:CHAR(26),nullzero,notnull"` // Which application id created this user? See gtsmodel.Application
|
||||
CreatedByApplication *Application `validate:"-" bun:"rel:belongs-to"` // Pointer to the application corresponding to createdbyapplicationID.
|
||||
LastEmailedAt time.Time `validate:"-" bun:",nullzero"` // When was this user last contacted by email.
|
||||
ConfirmationToken string `validate:"required_with=ConfirmationSentAt" bun:",nullzero"` // What confirmation token did we send this user/what are we expecting back?
|
||||
ConfirmationSentAt time.Time `validate:"required_with=ConfirmationToken" bun:",nullzero"` // When did we send email confirmation to this user?
|
||||
ConfirmedAt time.Time `validate:"required_with=Email" bun:",nullzero"` // When did the user confirm their email address
|
||||
UnconfirmedEmail string `validate:"required_without=Email" bun:",nullzero"` // Email address that hasn't yet been confirmed
|
||||
Moderator bool `validate:"-" bun:",nullzero,notnull,default:false"` // Is this user a moderator?
|
||||
Admin bool `validate:"-" bun:",nullzero,notnull,default:false"` // Is this user an admin?
|
||||
Disabled bool `validate:"-" bun:",nullzero,notnull,default:false"` // Is this user disabled from posting?
|
||||
Approved bool `validate:"-" bun:",nullzero,notnull,default:false"` // Has this user been approved by a moderator?
|
||||
ResetPasswordToken string `validate:"required_with=ResetPasswordSentAt" bun:",nullzero"` // The generated token that the user can use to reset their password
|
||||
ResetPasswordSentAt time.Time `validate:"required_with=ResetPasswordToken" bun:",nullzero"` // When did we email the user their reset-password email?
|
||||
|
||||
// id of this user in the local database; the end-user will never need to know this, it's strictly internal
|
||||
ID string `bun:"type:CHAR(26),pk,notnull,unique"`
|
||||
// confirmed email address for this user, this should be unique -- only one email address registered per instance, multiple users per email are not supported
|
||||
Email string `bun:"default:null,unique,nullzero"`
|
||||
// The id of the local gtsmodel.Account entry for this user, if it exists (unconfirmed users don't have an account yet)
|
||||
AccountID string `bun:"type:CHAR(26),unique,nullzero"`
|
||||
Account *Account `bun:"rel:belongs-to"`
|
||||
// The encrypted password of this user, generated using https://pkg.go.dev/golang.org/x/crypto/bcrypt#GenerateFromPassword. A salt is included so we're safe against 🌈 tables
|
||||
EncryptedPassword string `bun:",notnull"`
|
||||
|
||||
/*
|
||||
USER METADATA
|
||||
*/
|
||||
|
||||
// When was this user created?
|
||||
CreatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
|
||||
// From what IP was this user created?
|
||||
SignUpIP net.IP `bun:",nullzero"`
|
||||
// When was this user updated (eg., password changed, email address changed)?
|
||||
UpdatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
|
||||
// When did this user sign in for their current session?
|
||||
CurrentSignInAt time.Time `bun:",nullzero"`
|
||||
// What's the most recent IP of this user
|
||||
CurrentSignInIP net.IP `bun:",nullzero"`
|
||||
// When did this user last sign in?
|
||||
LastSignInAt time.Time `bun:",nullzero"`
|
||||
// What's the previous IP of this user?
|
||||
LastSignInIP net.IP `bun:",nullzero"`
|
||||
// How many times has this user signed in?
|
||||
SignInCount int
|
||||
// id of the user who invited this user (who let this guy in?)
|
||||
InviteID string `bun:"type:CHAR(26),nullzero"`
|
||||
// What languages does this user want to see?
|
||||
ChosenLanguages []string
|
||||
// What languages does this user not want to see?
|
||||
FilteredLanguages []string
|
||||
// In what timezone/locale is this user located?
|
||||
Locale string `bun:",nullzero"`
|
||||
// Which application id created this user? See gtsmodel.Application
|
||||
CreatedByApplicationID string `bun:"type:CHAR(26),nullzero"`
|
||||
CreatedByApplication *Application `bun:"rel:belongs-to"`
|
||||
// When did we last contact this user
|
||||
LastEmailedAt time.Time `bun:",nullzero"`
|
||||
|
||||
/*
|
||||
USER CONFIRMATION
|
||||
*/
|
||||
|
||||
// What confirmation token did we send this user/what are we expecting back?
|
||||
ConfirmationToken string `bun:",nullzero"`
|
||||
// When did the user confirm their email address
|
||||
ConfirmedAt time.Time `bun:",nullzero"`
|
||||
// When did we send email confirmation to this user?
|
||||
ConfirmationSentAt time.Time `bun:",nullzero"`
|
||||
// Email address that hasn't yet been confirmed
|
||||
UnconfirmedEmail string `bun:",nullzero"`
|
||||
|
||||
/*
|
||||
ACL FLAGS
|
||||
*/
|
||||
|
||||
// Is this user a moderator?
|
||||
Moderator bool
|
||||
// Is this user an admin?
|
||||
Admin bool
|
||||
// Is this user disabled from posting?
|
||||
Disabled bool
|
||||
// Has this user been approved by a moderator?
|
||||
Approved bool
|
||||
|
||||
/*
|
||||
USER SECURITY
|
||||
*/
|
||||
|
||||
// The generated token that the user can use to reset their password
|
||||
ResetPasswordToken string `bun:",nullzero"`
|
||||
// When did we email the user their reset-password email?
|
||||
ResetPasswordSentAt time.Time `bun:",nullzero"`
|
||||
|
||||
EncryptedOTPSecret string `bun:",nullzero"`
|
||||
EncryptedOTPSecretIv string `bun:",nullzero"`
|
||||
EncryptedOTPSecretSalt string `bun:",nullzero"`
|
||||
OTPRequiredForLogin bool
|
||||
OTPBackupCodes []string
|
||||
ConsumedTimestamp int
|
||||
RememberToken string `bun:",nullzero"`
|
||||
SignInToken string `bun:",nullzero"`
|
||||
SignInTokenSentAt time.Time `bun:",nullzero"`
|
||||
WebauthnID string `bun:",nullzero"`
|
||||
EncryptedOTPSecret string `validate:"-" bun:",nullzero"`
|
||||
EncryptedOTPSecretIv string `validate:"-" bun:",nullzero"`
|
||||
EncryptedOTPSecretSalt string `validate:"-" bun:",nullzero"`
|
||||
OTPRequiredForLogin bool `validate:"-" bun:",nullzero"`
|
||||
OTPBackupCodes []string `validate:"-" bun:",nullzero"`
|
||||
ConsumedTimestamp int `validate:"-" bun:",nullzero"`
|
||||
RememberToken string `validate:"-" bun:",nullzero"`
|
||||
SignInToken string `validate:"-" bun:",nullzero"`
|
||||
SignInTokenSentAt time.Time `validate:"-" bun:",nullzero"`
|
||||
WebauthnID string `validate:"-" bun:",nullzero"`
|
||||
}
|
||||
|
Reference in New Issue
Block a user