diff options
Diffstat (limited to 'internal/gtsmodel')
| -rw-r--r-- | internal/gtsmodel/account.go | 12 | ||||
| -rw-r--r-- | internal/gtsmodel/application.go | 18 | ||||
| -rw-r--r-- | internal/gtsmodel/block.go | 4 | ||||
| -rw-r--r-- | internal/gtsmodel/client.go | 12 | ||||
| -rw-r--r-- | internal/gtsmodel/domainblock.go | 20 | ||||
| -rw-r--r-- | internal/gtsmodel/emaildomainblock.go | 12 | ||||
| -rw-r--r-- | internal/gtsmodel/emoji.go | 6 | ||||
| -rw-r--r-- | internal/gtsmodel/follow.go | 4 | ||||
| -rw-r--r-- | internal/gtsmodel/followrequest.go | 4 | ||||
| -rw-r--r-- | internal/gtsmodel/instance.go | 6 | ||||
| -rw-r--r-- | internal/gtsmodel/mediaattachment.go | 24 | ||||
| -rw-r--r-- | internal/gtsmodel/mention.go | 22 | ||||
| -rw-r--r-- | internal/gtsmodel/notification.go | 4 | ||||
| -rw-r--r-- | internal/gtsmodel/routersession.go | 6 | ||||
| -rw-r--r-- | internal/gtsmodel/status.go | 4 | ||||
| -rw-r--r-- | internal/gtsmodel/statusbookmark.go | 18 | ||||
| -rw-r--r-- | internal/gtsmodel/statusfave.go | 20 | ||||
| -rw-r--r-- | internal/gtsmodel/statusmute.go | 18 | ||||
| -rw-r--r-- | internal/gtsmodel/tag.go | 18 | ||||
| -rw-r--r-- | internal/gtsmodel/token.go | 36 | ||||
| -rw-r--r-- | internal/gtsmodel/user.go | 60 | 
21 files changed, 164 insertions, 164 deletions
diff --git a/internal/gtsmodel/account.go b/internal/gtsmodel/account.go index ef4b66ecf..40f1ee726 100644 --- a/internal/gtsmodel/account.go +++ b/internal/gtsmodel/account.go @@ -30,8 +30,8 @@ import (  // Account represents either a local or a remote fediverse account, gotosocial or otherwise (mastodon, pleroma, etc).  type Account struct {  	ID                      string           `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`                                               // id of this item in the database -	CreatedAt               time.Time        `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"`                                          // when was item created -	UpdatedAt               time.Time        `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"`                                          // when was item last updated +	CreatedAt               time.Time        `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"`                                        // when was item created +	UpdatedAt               time.Time        `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"`                                        // when was item last updated  	Username                string           `validate:"required" bun:",nullzero,notnull,unique:userdomain"`                                                         // Username of the account, should just be a string of [a-zA-Z0-9_]. Can be added to domain to create the full username in the form ``[username]@[domain]`` eg., ``user_96@example.org``. Username and domain should be unique *with* each other  	Domain                  string           `validate:"omitempty,fqdn" bun:",nullzero,unique:userdomain"`                                                           // Domain of the account, will be null if this is a local account, otherwise something like ``example.org`` or ``mastodon.social``. Should be unique with username.  	AvatarMediaAttachmentID string           `validate:"omitempty,ulid" bun:"type:CHAR(26),nullzero"`                                                                // Database ID of the media attachment, if present @@ -55,7 +55,7 @@ type Account struct {  	Language                string           `validate:"omitempty,bcp47_language_tag" bun:",nullzero,notnull,default:'en'"`                                          // What language does this account post in?  	URI                     string           `validate:"required,url" bun:",nullzero,notnull,unique"`                                                                // ActivityPub URI for this account.  	URL                     string           `validate:"required_without=Domain,omitempty,url" bun:",nullzero,unique"`                                               // Web URL for this account's profile -	LastWebfingeredAt       time.Time        `validate:"required_with=Domain" bun:"type:timestamp,nullzero"`                                                         // Last time this account was refreshed/located with webfinger. +	LastWebfingeredAt       time.Time        `validate:"required_with=Domain" bun:"type:timestamptz,nullzero"`                                                       // Last time this account was refreshed/located with webfinger.  	InboxURI                string           `validate:"required_without=Domain,omitempty,url" bun:",nullzero,unique"`                                               // Address of this account's ActivityPub inbox, for sending activity to  	OutboxURI               string           `validate:"required_without=Domain,omitempty,url" bun:",nullzero,unique"`                                               // Address of this account's activitypub outbox  	FollowingURI            string           `validate:"required_without=Domain,omitempty,url" bun:",nullzero,unique"`                                               // URI for getting the following list of this account @@ -65,9 +65,9 @@ type Account struct {  	PrivateKey              *rsa.PrivateKey  `validate:"required_without=Domain"`                                                                                    // Privatekey for validating activitypub requests, will only be defined for local accounts  	PublicKey               *rsa.PublicKey   `validate:"required"`                                                                                                   // Publickey for encoding activitypub requests, will be defined for both local and remote accounts  	PublicKeyURI            string           `validate:"required,url" bun:",nullzero,notnull,unique"`                                                                // Web-reachable location of this account's public key -	SensitizedAt            time.Time        `validate:"-" bun:"type:timestamp,nullzero"`                                                                            // When was this account set to have all its media shown as sensitive? -	SilencedAt              time.Time        `validate:"-" bun:"type:timestamp,nullzero"`                                                                            // When was this account silenced (eg., statuses only visible to followers, not public)? -	SuspendedAt             time.Time        `validate:"-" bun:"type:timestamp,nullzero"`                                                                            // When was this account suspended (eg., don't allow it to log in/post, don't accept media/posts from this account) +	SensitizedAt            time.Time        `validate:"-" bun:"type:timestamptz,nullzero"`                                                                          // When was this account set to have all its media shown as sensitive? +	SilencedAt              time.Time        `validate:"-" bun:"type:timestamptz,nullzero"`                                                                          // When was this account silenced (eg., statuses only visible to followers, not public)? +	SuspendedAt             time.Time        `validate:"-" bun:"type:timestamptz,nullzero"`                                                                          // When was this account suspended (eg., don't allow it to log in/post, don't accept media/posts from this account)  	HideCollections         bool             `validate:"-" bun:",default:false"`                                                                                     // Hide this account's collections  	SuspensionOrigin        string           `validate:"omitempty,ulid" bun:"type:CHAR(26),nullzero"`                                                                // id of the database entry that caused this account to become suspended -- can be an account ID or a domain block ID  } diff --git a/internal/gtsmodel/application.go b/internal/gtsmodel/application.go index de37c8d61..29058426a 100644 --- a/internal/gtsmodel/application.go +++ b/internal/gtsmodel/application.go @@ -23,13 +23,13 @@ import "time"  // Application represents an application that can perform actions on behalf of a user.  // It is used to authorize tokens etc, and is associated with an oauth client id in the database.  type Application struct { -	ID           string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`      // id of this item in the database -	CreatedAt    time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item created -	UpdatedAt    time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item last updated -	Name         string    `validate:"required" bun:",notnull"`                                           // name of the application given when it was created (eg., 'tusky') -	Website      string    `validate:"omitempty,url" bun:",nullzero"`                                     // website for the application given when it was created (eg., 'https://tusky.app') -	RedirectURI  string    `validate:"required,uri" bun:",nullzero,notnull"`                              // redirect uri requested by the application for oauth2 flow -	ClientID     string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                // id of the associated oauth client entity in the db -	ClientSecret string    `validate:"required,uuid" bun:",nullzero,notnull"`                             // secret of the associated oauth client entity in the db -	Scopes       string    `validate:"required" bun:",notnull"`                                           // scopes requested when this app was created +	ID           string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`        // id of this item in the database +	CreatedAt    time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item created +	UpdatedAt    time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item last updated +	Name         string    `validate:"required" bun:",notnull"`                                             // name of the application given when it was created (eg., 'tusky') +	Website      string    `validate:"omitempty,url" bun:",nullzero"`                                       // website for the application given when it was created (eg., 'https://tusky.app') +	RedirectURI  string    `validate:"required,uri" bun:",nullzero,notnull"`                                // redirect uri requested by the application for oauth2 flow +	ClientID     string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                  // id of the associated oauth client entity in the db +	ClientSecret string    `validate:"required,uuid" bun:",nullzero,notnull"`                               // secret of the associated oauth client entity in the db +	Scopes       string    `validate:"required" bun:",notnull"`                                             // scopes requested when this app was created  } diff --git a/internal/gtsmodel/block.go b/internal/gtsmodel/block.go index 778ac45be..5a9b59c2c 100644 --- a/internal/gtsmodel/block.go +++ b/internal/gtsmodel/block.go @@ -23,8 +23,8 @@ import "time"  // Block refers to the blocking of one account by another.  type Block struct {  	ID              string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`             // id of this item in the database -	CreatedAt       time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"`        // when was item created -	UpdatedAt       time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"`        // when was item last updated +	CreatedAt       time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"`      // when was item created +	UpdatedAt       time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"`      // when was item last updated  	URI             string    `validate:"required,url" bun:",notnull,nullzero,unique"`                              // ActivityPub uri of this block.  	AccountID       string    `validate:"required,ulid" bun:"type:CHAR(26),unique:blocksrctarget,notnull,nullzero"` // Who does this block originate from?  	Account         *Account  `validate:"-" bun:"rel:belongs-to"`                                                   // Account corresponding to accountID diff --git a/internal/gtsmodel/client.go b/internal/gtsmodel/client.go index e924bd190..20ca03897 100644 --- a/internal/gtsmodel/client.go +++ b/internal/gtsmodel/client.go @@ -22,10 +22,10 @@ import "time"  // Client is a wrapper for OAuth client details.  type Client struct { -	ID        string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`      // id of this item in the database -	CreatedAt time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item created -	UpdatedAt time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item last updated -	Secret    string    `validate:"required,uuid" bun:",nullzero,notnull"`                             // secret generated when client was created -	Domain    string    `validate:"required,uri" bun:",nullzero,notnull"`                              // domain requested for client -	UserID    string    `validate:"omitempty,ulid" bun:"type:CHAR(26),nullzero"`                       // id of the user that this client acts on behalf of +	ID        string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`        // id of this item in the database +	CreatedAt time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item created +	UpdatedAt time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item last updated +	Secret    string    `validate:"required,uuid" bun:",nullzero,notnull"`                               // secret generated when client was created +	Domain    string    `validate:"required,uri" bun:",nullzero,notnull"`                                // domain requested for client +	UserID    string    `validate:"omitempty,ulid" bun:"type:CHAR(26),nullzero"`                         // id of the user that this client acts on behalf of  } diff --git a/internal/gtsmodel/domainblock.go b/internal/gtsmodel/domainblock.go index 8490b45bf..da3368e0c 100644 --- a/internal/gtsmodel/domainblock.go +++ b/internal/gtsmodel/domainblock.go @@ -22,14 +22,14 @@ import "time"  // DomainBlock represents a federation block against a particular domain  type DomainBlock struct { -	ID                 string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`      // id of this item in the database -	CreatedAt          time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item created -	UpdatedAt          time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item last updated -	Domain             string    `validate:"required,fqdn" bun:",nullzero,notnull"`                             // domain to block. Eg. 'whatever.com' -	CreatedByAccountID string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                // Account ID of the creator of this block -	CreatedByAccount   *Account  `validate:"-" bun:"rel:belongs-to"`                                            // Account corresponding to createdByAccountID -	PrivateComment     string    `validate:"-" bun:""`                                                          // Private comment on this block, viewable to admins -	PublicComment      string    `validate:"-" bun:""`                                                          // Public comment on this block, viewable (optionally) by everyone -	Obfuscate          bool      `validate:"-" bun:",default:false"`                                            // whether the domain name should appear obfuscated when displaying it publicly -	SubscriptionID     string    `validate:"omitempty,ulid" bun:"type:CHAR(26),nullzero"`                       // if this block was created through a subscription, what's the subscription ID? +	ID                 string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`        // id of this item in the database +	CreatedAt          time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item created +	UpdatedAt          time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item last updated +	Domain             string    `validate:"required,fqdn" bun:",nullzero,notnull"`                               // domain to block. Eg. 'whatever.com' +	CreatedByAccountID string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                  // Account ID of the creator of this block +	CreatedByAccount   *Account  `validate:"-" bun:"rel:belongs-to"`                                              // Account corresponding to createdByAccountID +	PrivateComment     string    `validate:"-" bun:""`                                                            // Private comment on this block, viewable to admins +	PublicComment      string    `validate:"-" bun:""`                                                            // Public comment on this block, viewable (optionally) by everyone +	Obfuscate          bool      `validate:"-" bun:",default:false"`                                              // whether the domain name should appear obfuscated when displaying it publicly +	SubscriptionID     string    `validate:"omitempty,ulid" bun:"type:CHAR(26),nullzero"`                         // if this block was created through a subscription, what's the subscription ID?  } diff --git a/internal/gtsmodel/emaildomainblock.go b/internal/gtsmodel/emaildomainblock.go index 2118068f2..43a6ce2be 100644 --- a/internal/gtsmodel/emaildomainblock.go +++ b/internal/gtsmodel/emaildomainblock.go @@ -22,10 +22,10 @@ import "time"  // EmailDomainBlock represents a domain that the server should automatically reject sign-up requests from.  type EmailDomainBlock struct { -	ID                 string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`      // id of this item in the database -	CreatedAt          time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item created -	UpdatedAt          time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item last updated -	Domain             string    `validate:"required,fqdn" bun:",nullzero,notnull"`                             // Email domain to block. Eg. 'gmail.com' or 'hotmail.com' -	CreatedByAccountID string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                // Account ID of the creator of this block -	CreatedByAccount   *Account  `validate:"-" bun:"rel:belongs-to"`                                            // Account corresponding to createdByAccountID +	ID                 string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`        // id of this item in the database +	CreatedAt          time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item created +	UpdatedAt          time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item last updated +	Domain             string    `validate:"required,fqdn" bun:",nullzero,notnull"`                               // Email domain to block. Eg. 'gmail.com' or 'hotmail.com' +	CreatedByAccountID string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                  // Account ID of the creator of this block +	CreatedByAccount   *Account  `validate:"-" bun:"rel:belongs-to"`                                              // Account corresponding to createdByAccountID  } diff --git a/internal/gtsmodel/emoji.go b/internal/gtsmodel/emoji.go index ac9f753fc..7db8c694c 100644 --- a/internal/gtsmodel/emoji.go +++ b/internal/gtsmodel/emoji.go @@ -23,8 +23,8 @@ import "time"  // Emoji represents a custom emoji that's been uploaded through the admin UI, and is useable by instance denizens.  type Emoji struct {  	ID                     string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`                                // id of this item in the database -	CreatedAt              time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"`                           // when was item created -	UpdatedAt              time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"`                           // when was item last updated +	CreatedAt              time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"`                         // when was item created +	UpdatedAt              time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"`                         // when was item last updated  	Shortcode              string    `validate:"required" bun:",nullzero,notnull,unique:shortcodedomain"`                                     // String shortcode for this emoji -- the part that's between colons. This should be lowercase a-z_  eg., 'blob_hug' 'purple_heart' Must be unique with domain.  	Domain                 string    `validate:"omitempty,fqdn" bun:",notnull,default:'',unique:shortcodedomain"`                             // Origin domain of this emoji, eg 'example.org', 'queer.party'. empty string for local emojis.  	ImageRemoteURL         string    `validate:"required_without=ImageURL,omitempty,url" bun:",nullzero"`                                     // Where can this emoji be retrieved remotely? Null for local emojis. @@ -37,7 +37,7 @@ type Emoji struct {  	ImageStaticContentType string    `validate:"required" bun:",nullzero,notnull"`                                                            // MIME content type of the static version of the emoji image.  	ImageFileSize          int       `validate:"required,min=1" bun:",nullzero,notnull"`                                                      // Size of the emoji image file in bytes, for serving purposes.  	ImageStaticFileSize    int       `validate:"required,min=1" bun:",nullzero,notnull"`                                                      // Size of the static version of the emoji image file in bytes, for serving purposes. -	ImageUpdatedAt         time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"`                           // When was the emoji image last updated? +	ImageUpdatedAt         time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"`                         // When was the emoji image last updated?  	Disabled               bool      `validate:"-" bun:",notnull,default:false"`                                                              // Has a moderation action disabled this emoji from being shown?  	URI                    string    `validate:"url" bun:",nullzero,notnull,unique"`                                                          // ActivityPub uri of this emoji. Something like 'https://example.org/emojis/1234'  	VisibleInPicker        bool      `validate:"-" bun:",notnull,default:true"`                                                               // Is this emoji visible in the admin emoji picker? diff --git a/internal/gtsmodel/follow.go b/internal/gtsmodel/follow.go index b5908277d..dc54970dd 100644 --- a/internal/gtsmodel/follow.go +++ b/internal/gtsmodel/follow.go @@ -23,8 +23,8 @@ import "time"  // Follow represents one account following another, and the metadata around that follow.  type Follow struct {  	ID              string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`        // id of this item in the database -	CreatedAt       time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"`   // when was item created -	UpdatedAt       time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"`   // when was item last updated +	CreatedAt       time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item created +	UpdatedAt       time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item last updated  	URI             string    `validate:"required,url" bun:",notnull,nullzero,unique"`                         // ActivityPub uri of this follow.  	AccountID       string    `validate:"required,ulid" bun:"type:CHAR(26),unique:srctarget,notnull,nullzero"` // Who does this follow originate from?  	Account         *Account  `validate:"-" bun:"rel:belongs-to"`                                              // Account corresponding to accountID diff --git a/internal/gtsmodel/followrequest.go b/internal/gtsmodel/followrequest.go index fe77d56f2..aad25e688 100644 --- a/internal/gtsmodel/followrequest.go +++ b/internal/gtsmodel/followrequest.go @@ -23,8 +23,8 @@ import "time"  // FollowRequest represents one account requesting to follow another, and the metadata around that request.  type FollowRequest struct {  	ID              string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`          // id of this item in the database -	CreatedAt       time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"`     // when was item created -	UpdatedAt       time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"`     // when was item last updated +	CreatedAt       time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"`   // when was item created +	UpdatedAt       time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"`   // when was item last updated  	URI             string    `validate:"required,url" bun:",notnull,nullzero,unique"`                           // ActivityPub uri of this follow (request).  	AccountID       string    `validate:"required,ulid" bun:"type:CHAR(26),unique:frsrctarget,notnull,nullzero"` // Who does this follow request originate from?  	Account         *Account  `validate:"-" bun:"rel:belongs-to"`                                                // Account corresponding to accountID diff --git a/internal/gtsmodel/instance.go b/internal/gtsmodel/instance.go index 4d8c5af3c..4193a44e2 100644 --- a/internal/gtsmodel/instance.go +++ b/internal/gtsmodel/instance.go @@ -23,12 +23,12 @@ import "time"  // Instance represents a federated instance, either local or remote.  type Instance struct {  	ID                     string       `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`                     // id of this item in the database -	CreatedAt              time.Time    `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"`                // when was item created -	UpdatedAt              time.Time    `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"`                // when was item last updated +	CreatedAt              time.Time    `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"`              // when was item created +	UpdatedAt              time.Time    `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"`              // when was item last updated  	Domain                 string       `validate:"required,fqdn" bun:",nullzero,notnull,unique"`                                     // Instance domain eg example.org  	Title                  string       `validate:"-" bun:""`                                                                         // Title of this instance as it would like to be displayed.  	URI                    string       `validate:"required,url" bun:",nullzero,notnull,unique"`                                      // base URI of this instance eg https://example.org -	SuspendedAt            time.Time    `validate:"-" bun:"type:timestamp,nullzero"`                                                  // When was this instance suspended, if at all? +	SuspendedAt            time.Time    `validate:"-" bun:"type:timestamptz,nullzero"`                                                // When was this instance suspended, if at all?  	DomainBlockID          string       `validate:"omitempty,ulid" bun:"type:CHAR(26),nullzero"`                                      // ID of any existing domain block for this instance in the database  	DomainBlock            *DomainBlock `validate:"-" bun:"rel:belongs-to"`                                                           // Domain block corresponding to domainBlockID  	ShortDescription       string       `validate:"-" bun:""`                                                                         // Short description of this instance diff --git a/internal/gtsmodel/mediaattachment.go b/internal/gtsmodel/mediaattachment.go index 4c7e0f843..5d4af8e68 100644 --- a/internal/gtsmodel/mediaattachment.go +++ b/internal/gtsmodel/mediaattachment.go @@ -26,8 +26,8 @@ import (  // somewhere in storage and that can be retrieved and served by the router.  type MediaAttachment struct {  	ID                string           `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`                       // id of this item in the database -	CreatedAt         time.Time        `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"`                  // when was item created -	UpdatedAt         time.Time        `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"`                  // when was item last updated +	CreatedAt         time.Time        `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"`                // when was item created +	UpdatedAt         time.Time        `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"`                // when was item last updated  	StatusID          string           `validate:"omitempty,ulid" bun:"type:CHAR(26),nullzero"`                                        // ID of the status to which this is attached  	URL               string           `validate:"required_without=RemoteURL,omitempty,url" bun:",nullzero"`                           // Where can the attachment be retrieved on *this* server  	RemoteURL         string           `validate:"required_without=URL,omitempty,url" bun:",nullzero"`                                 // Where can the attachment be retrieved on a remote server (empty for local media) @@ -47,20 +47,20 @@ type MediaAttachment struct {  // File refers to the metadata for the whole file  type File struct { -	Path        string    `validate:"required,file" bun:",nullzero,notnull"`                             // Path of the file in storage. -	ContentType string    `validate:"required" bun:",nullzero,notnull"`                                  // MIME content type of the file. -	FileSize    int       `validate:"required" bun:",notnull"`                                           // File size in bytes -	UpdatedAt   time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // When was the file last updated. +	Path        string    `validate:"required,file" bun:",nullzero,notnull"`                               // Path of the file in storage. +	ContentType string    `validate:"required" bun:",nullzero,notnull"`                                    // MIME content type of the file. +	FileSize    int       `validate:"required" bun:",notnull"`                                             // File size in bytes +	UpdatedAt   time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // When was the file last updated.  }  // Thumbnail refers to a small image thumbnail derived from a larger image, video, or audio file.  type Thumbnail struct { -	Path        string    `validate:"required,file" bun:",nullzero,notnull"`                             // Path of the file in storage. -	ContentType string    `validate:"required" bun:",nullzero,notnull"`                                  // MIME content type of the file. -	FileSize    int       `validate:"required" bun:",notnull"`                                           // File size in bytes -	UpdatedAt   time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // When was the file last updated. -	URL         string    `validate:"required_without=RemoteURL,omitempty,url" bun:",nullzero"`          // What is the URL of the thumbnail on the local server -	RemoteURL   string    `validate:"required_without=URL,omitempty,url" bun:",nullzero"`                // What is the remote URL of the thumbnail (empty for local media) +	Path        string    `validate:"required,file" bun:",nullzero,notnull"`                               // Path of the file in storage. +	ContentType string    `validate:"required" bun:",nullzero,notnull"`                                    // MIME content type of the file. +	FileSize    int       `validate:"required" bun:",notnull"`                                             // File size in bytes +	UpdatedAt   time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // When was the file last updated. +	URL         string    `validate:"required_without=RemoteURL,omitempty,url" bun:",nullzero"`            // What is the URL of the thumbnail on the local server +	RemoteURL   string    `validate:"required_without=URL,omitempty,url" bun:",nullzero"`                  // What is the remote URL of the thumbnail (empty for local media)  }  // ProcessingStatus refers to how far along in the processing stage the attachment is. diff --git a/internal/gtsmodel/mention.go b/internal/gtsmodel/mention.go index 492740d77..81b9b9e72 100644 --- a/internal/gtsmodel/mention.go +++ b/internal/gtsmodel/mention.go @@ -22,17 +22,17 @@ import "time"  // Mention refers to the 'tagging' or 'mention' of a user within a status.  type Mention struct { -	ID               string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`      // id of this item in the database -	CreatedAt        time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item created -	UpdatedAt        time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item last updated -	StatusID         string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                // ID of the status this mention originates from -	Status           *Status   `validate:"-" bun:"rel:belongs-to"`                                            // status referred to by statusID -	OriginAccountID  string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                // ID of the mention creator account -	OriginAccountURI string    `validate:"url" bun:",nullzero,notnull"`                                       // ActivityPub URI of the originator/creator of the mention -	OriginAccount    *Account  `validate:"-" bun:"rel:belongs-to"`                                            // account referred to by originAccountID -	TargetAccountID  string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                // Mention target/receiver account ID -	TargetAccount    *Account  `validate:"-" bun:"rel:belongs-to"`                                            // account referred to by targetAccountID -	Silent           bool      `validate:"-" bun:",notnull,default:false"`                                    // Prevent this mention from generating a notification? +	ID               string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`        // id of this item in the database +	CreatedAt        time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item created +	UpdatedAt        time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item last updated +	StatusID         string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                  // ID of the status this mention originates from +	Status           *Status   `validate:"-" bun:"rel:belongs-to"`                                              // status referred to by statusID +	OriginAccountID  string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                  // ID of the mention creator account +	OriginAccountURI string    `validate:"url" bun:",nullzero,notnull"`                                         // ActivityPub URI of the originator/creator of the mention +	OriginAccount    *Account  `validate:"-" bun:"rel:belongs-to"`                                              // account referred to by originAccountID +	TargetAccountID  string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                  // Mention target/receiver account ID +	TargetAccount    *Account  `validate:"-" bun:"rel:belongs-to"`                                              // account referred to by targetAccountID +	Silent           bool      `validate:"-" bun:",notnull,default:false"`                                      // Prevent this mention from generating a notification?  	/*  		NON-DATABASE CONVENIENCE FIELDS diff --git a/internal/gtsmodel/notification.go b/internal/gtsmodel/notification.go index 1b1f39a77..013e8ba35 100644 --- a/internal/gtsmodel/notification.go +++ b/internal/gtsmodel/notification.go @@ -23,8 +23,8 @@ import "time"  // Notification models an alert/notification sent to an account about something like a reblog, like, new follow request, etc.  type Notification struct {  	ID               string           `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`                                                                                                                                    // id of this item in the database -	CreatedAt        time.Time        `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"`                                                                                                                               // when was item created -	UpdatedAt        time.Time        `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"`                                                                                                                               // when was item last updated                                                                                                                            // when was item created +	CreatedAt        time.Time        `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"`                                                                                                                             // when was item created +	UpdatedAt        time.Time        `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"`                                                                                                                             // when was item last updated                                                                                                                            // when was item created  	NotificationType NotificationType `validate:"oneof=follow follow_request mention reblog favourite poll status" bun:",nullzero,notnull"`                                                                                                        // Type of this notification  	TargetAccountID  string           `validate:"ulid" bun:"type:CHAR(26),nullzero,notnull"`                                                                                                                                                       // Which account does this notification target (ie., who will receive the notification?)  	TargetAccount    *Account         `validate:"-" bun:"rel:belongs-to"`                                                                                                                                                                          // Which account performed the action that created this notification? diff --git a/internal/gtsmodel/routersession.go b/internal/gtsmodel/routersession.go index 3edb8bc36..34c1744bd 100644 --- a/internal/gtsmodel/routersession.go +++ b/internal/gtsmodel/routersession.go @@ -22,9 +22,9 @@ import "time"  // RouterSession is used to store and retrieve settings for a router session.  type RouterSession struct { -	ID        string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`      // id of this item in the database -	CreatedAt time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item created -	UpdatedAt time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item last updated +	ID        string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`        // id of this item in the database +	CreatedAt time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item created +	UpdatedAt time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item last updated  	Auth      []byte    `validate:"required,len=32" bun:"type:bytea,notnull,nullzero"`  	Crypt     []byte    `validate:"required,len=32" bun:"type:bytea,notnull,nullzero"`  } diff --git a/internal/gtsmodel/status.go b/internal/gtsmodel/status.go index 55488362e..e0c339659 100644 --- a/internal/gtsmodel/status.go +++ b/internal/gtsmodel/status.go @@ -25,8 +25,8 @@ import (  // Status represents a user-created 'post' or 'status' in the database, either remote or local  type Status struct {  	ID                       string             `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`                              // id of this item in the database -	CreatedAt                time.Time          `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"`                         // when was item created -	UpdatedAt                time.Time          `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"`                         // when was item last updated +	CreatedAt                time.Time          `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"`                       // when was item created +	UpdatedAt                time.Time          `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"`                       // when was item last updated  	URI                      string             `validate:"required,url" bun:",unique,nullzero,notnull"`                                               // activitypub URI of this status  	URL                      string             `validate:"url" bun:",nullzero"`                                                                       // web url for viewing this status  	Content                  string             `validate:"-" bun:""`                                                                                  // content of this status; likely html-formatted but not guaranteed diff --git a/internal/gtsmodel/statusbookmark.go b/internal/gtsmodel/statusbookmark.go index 3dcf4cb92..73a22aeba 100644 --- a/internal/gtsmodel/statusbookmark.go +++ b/internal/gtsmodel/statusbookmark.go @@ -22,13 +22,13 @@ import "time"  // StatusBookmark refers to one account having a 'bookmark' of the status of another account.  type StatusBookmark struct { -	ID              string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`      // id of this item in the database -	CreatedAt       time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item created -	UpdatedAt       time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item last updated -	AccountID       string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                // id of the account that created ('did') the bookmark -	Account         *Account  `validate:"-" bun:"rel:belongs-to"`                                            // account that created the bookmark -	TargetAccountID string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                // id the account owning the bookmarked status -	TargetAccount   *Account  `validate:"-" bun:"rel:belongs-to"`                                            // account owning the bookmarked status -	StatusID        string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                // database id of the status that has been bookmarked -	Status          *Status   `validate:"-" bun:"rel:belongs-to"`                                            // the bookmarked status +	ID              string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`        // id of this item in the database +	CreatedAt       time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item created +	UpdatedAt       time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item last updated +	AccountID       string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                  // id of the account that created ('did') the bookmark +	Account         *Account  `validate:"-" bun:"rel:belongs-to"`                                              // account that created the bookmark +	TargetAccountID string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                  // id the account owning the bookmarked status +	TargetAccount   *Account  `validate:"-" bun:"rel:belongs-to"`                                              // account owning the bookmarked status +	StatusID        string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                  // database id of the status that has been bookmarked +	Status          *Status   `validate:"-" bun:"rel:belongs-to"`                                              // the bookmarked status  } diff --git a/internal/gtsmodel/statusfave.go b/internal/gtsmodel/statusfave.go index 93bcda0e6..72a98bd17 100644 --- a/internal/gtsmodel/statusfave.go +++ b/internal/gtsmodel/statusfave.go @@ -22,14 +22,14 @@ import "time"  // StatusFave refers to a 'fave' or 'like' in the database, from one account, targeting the status of another account  type StatusFave struct { -	ID              string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`      // id of this item in the database -	CreatedAt       time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item created -	UpdatedAt       time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item last updated -	AccountID       string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                // id of the account that created ('did') the fave -	Account         *Account  `validate:"-" bun:"rel:belongs-to"`                                            // account that created the fave -	TargetAccountID string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                // id the account owning the faved status -	TargetAccount   *Account  `validate:"-" bun:"rel:belongs-to"`                                            // account owning the faved status -	StatusID        string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                // database id of the status that has been 'faved' -	Status          *Status   `validate:"-" bun:"rel:belongs-to"`                                            // the faved status -	URI             string    `validate:"required,url" bun:",nullzero,notnull"`                              // ActivityPub URI of this fave +	ID              string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`        // id of this item in the database +	CreatedAt       time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item created +	UpdatedAt       time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item last updated +	AccountID       string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                  // id of the account that created ('did') the fave +	Account         *Account  `validate:"-" bun:"rel:belongs-to"`                                              // account that created the fave +	TargetAccountID string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                  // id the account owning the faved status +	TargetAccount   *Account  `validate:"-" bun:"rel:belongs-to"`                                              // account owning the faved status +	StatusID        string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                  // database id of the status that has been 'faved' +	Status          *Status   `validate:"-" bun:"rel:belongs-to"`                                              // the faved status +	URI             string    `validate:"required,url" bun:",nullzero,notnull"`                                // ActivityPub URI of this fave  } diff --git a/internal/gtsmodel/statusmute.go b/internal/gtsmodel/statusmute.go index 2c03b8085..849a28c82 100644 --- a/internal/gtsmodel/statusmute.go +++ b/internal/gtsmodel/statusmute.go @@ -22,13 +22,13 @@ import "time"  // StatusMute refers to one account having muted the status of another account or its own.  type StatusMute struct { -	ID              string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`      // id of this item in the database -	CreatedAt       time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item created -	UpdatedAt       time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item last updated -	AccountID       string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                // id of the account that created ('did') the mute -	Account         *Account  `validate:"-" bun:"rel:belongs-to"`                                            // pointer to the account specified by accountID -	TargetAccountID string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                // id the account owning the muted status (can be the same as accountID) -	TargetAccount   *Account  `validate:"-" bun:"rel:belongs-to"`                                            // pointer to the account specified by targetAccountID -	StatusID        string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                // database id of the status that has been muted -	Status          *Status   `validate:"-" bun:"rel:belongs-to"`                                            // pointer to the muted status specified by statusID +	ID              string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`        // id of this item in the database +	CreatedAt       time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item created +	UpdatedAt       time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item last updated +	AccountID       string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                  // id of the account that created ('did') the mute +	Account         *Account  `validate:"-" bun:"rel:belongs-to"`                                              // pointer to the account specified by accountID +	TargetAccountID string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                  // id the account owning the muted status (can be the same as accountID) +	TargetAccount   *Account  `validate:"-" bun:"rel:belongs-to"`                                              // pointer to the account specified by targetAccountID +	StatusID        string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                  // database id of the status that has been muted +	Status          *Status   `validate:"-" bun:"rel:belongs-to"`                                              // pointer to the muted status specified by statusID  } diff --git a/internal/gtsmodel/tag.go b/internal/gtsmodel/tag.go index 295447c4f..0bb9daf0b 100644 --- a/internal/gtsmodel/tag.go +++ b/internal/gtsmodel/tag.go @@ -22,13 +22,13 @@ import "time"  // Tag represents a hashtag for gathering public statuses together.  type Tag struct { -	ID                     string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`      // id of this item in the database -	CreatedAt              time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item created -	UpdatedAt              time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item last updated -	URL                    string    `validate:"required,url" bun:",nullzero,notnull"`                              // Href/web address of this tag, eg https://example.org/tags/somehashtag -	Name                   string    `validate:"required" bun:",unique,nullzero,notnull"`                           // name of this tag -- the tag without the hash part -	FirstSeenFromAccountID string    `validate:"omitempty,ulid" bun:"type:CHAR(26),nullzero"`                       // Which account ID is the first one we saw using this tag? -	Useable                bool      `validate:"-" bun:",notnull,default:true"`                                     // can our instance users use this tag? -	Listable               bool      `validate:"-" bun:",notnull,default:true"`                                     // can our instance users look up this tag? -	LastStatusAt           time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was this tag last used? +	ID                     string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`        // id of this item in the database +	CreatedAt              time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item created +	UpdatedAt              time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item last updated +	URL                    string    `validate:"required,url" bun:",nullzero,notnull"`                                // Href/web address of this tag, eg https://example.org/tags/somehashtag +	Name                   string    `validate:"required" bun:",unique,nullzero,notnull"`                             // name of this tag -- the tag without the hash part +	FirstSeenFromAccountID string    `validate:"omitempty,ulid" bun:"type:CHAR(26),nullzero"`                         // Which account ID is the first one we saw using this tag? +	Useable                bool      `validate:"-" bun:",notnull,default:true"`                                       // can our instance users use this tag? +	Listable               bool      `validate:"-" bun:",notnull,default:true"`                                       // can our instance users look up this tag? +	LastStatusAt           time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was this tag last used?  } diff --git a/internal/gtsmodel/token.go b/internal/gtsmodel/token.go index 25601dd01..19779c100 100644 --- a/internal/gtsmodel/token.go +++ b/internal/gtsmodel/token.go @@ -22,22 +22,22 @@ import "time"  // Token is a translation of the gotosocial token with the ExpiresIn fields replaced with ExpiresAt.  type Token struct { -	ID                  string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`      // id of this item in the database -	CreatedAt           time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item created -	UpdatedAt           time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item last updated -	ClientID            string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                // ID of the client who owns this token -	UserID              string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero"`                        // ID of the user who owns this token -	RedirectURI         string    `validate:"required,uri" bun:",nullzero,notnull"`                              // Oauth redirect URI for this token -	Scope               string    `validate:"required" bun:",notnull"`                                           // Oauth scope -	Code                string    `validate:"-" bun:",pk,nullzero,notnull,default:''"`                           // Code, if present -	CodeChallenge       string    `validate:"-" bun:",nullzero"`                                                 // Code challenge, if code present -	CodeChallengeMethod string    `validate:"-" bun:",nullzero"`                                                 // Code challenge method, if code present -	CodeCreateAt        time.Time `validate:"required_with=Code" bun:"type:timestamp,nullzero"`                  // Code created time, if code present -	CodeExpiresAt       time.Time `validate:"-" bun:"type:timestamp,nullzero"`                                   // Code expires at -- null means the code never expires -	Access              string    `validate:"-" bun:",pk,nullzero,notnull,default:''"`                           // User level access token, if present -	AccessCreateAt      time.Time `validate:"required_with=Access" bun:"type:timestamp,nullzero"`                // User level access token created time, if access present -	AccessExpiresAt     time.Time `validate:"-" bun:"type:timestamp,nullzero"`                                   // User level access token expires at -- null means the token never expires -	Refresh             string    `validate:"-" bun:",pk,nullzero,notnull,default:''"`                           // Refresh token, if present -	RefreshCreateAt     time.Time `validate:"required_with=Refresh" bun:"type:timestamp,nullzero"`               // Refresh created at, if refresh present -	RefreshExpiresAt    time.Time `validate:"-" bun:"type:timestamp,nullzero"`                                   // Refresh expires at -- null means the refresh token never expires +	ID                  string    `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`        // id of this item in the database +	CreatedAt           time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item created +	UpdatedAt           time.Time `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item last updated +	ClientID            string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`                  // ID of the client who owns this token +	UserID              string    `validate:"required,ulid" bun:"type:CHAR(26),nullzero"`                          // ID of the user who owns this token +	RedirectURI         string    `validate:"required,uri" bun:",nullzero,notnull"`                                // Oauth redirect URI for this token +	Scope               string    `validate:"required" bun:",notnull"`                                             // Oauth scope +	Code                string    `validate:"-" bun:",pk,nullzero,notnull,default:''"`                             // Code, if present +	CodeChallenge       string    `validate:"-" bun:",nullzero"`                                                   // Code challenge, if code present +	CodeChallengeMethod string    `validate:"-" bun:",nullzero"`                                                   // Code challenge method, if code present +	CodeCreateAt        time.Time `validate:"required_with=Code" bun:"type:timestamptz,nullzero"`                  // Code created time, if code present +	CodeExpiresAt       time.Time `validate:"-" bun:"type:timestamptz,nullzero"`                                   // Code expires at -- null means the code never expires +	Access              string    `validate:"-" bun:",pk,nullzero,notnull,default:''"`                             // User level access token, if present +	AccessCreateAt      time.Time `validate:"required_with=Access" bun:"type:timestamptz,nullzero"`                // User level access token created time, if access present +	AccessExpiresAt     time.Time `validate:"-" bun:"type:timestamptz,nullzero"`                                   // User level access token expires at -- null means the token never expires +	Refresh             string    `validate:"-" bun:",pk,nullzero,notnull,default:''"`                             // Refresh token, if present +	RefreshCreateAt     time.Time `validate:"required_with=Refresh" bun:"type:timestamptz,nullzero"`               // Refresh created at, if refresh present +	RefreshExpiresAt    time.Time `validate:"-" bun:"type:timestamptz,nullzero"`                                   // Refresh expires at -- null means the refresh token never expires  } diff --git a/internal/gtsmodel/user.go b/internal/gtsmodel/user.go index b49a8b28b..481e126b1 100644 --- a/internal/gtsmodel/user.go +++ b/internal/gtsmodel/user.go @@ -26,34 +26,34 @@ 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 { -	ID                     string       `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`      // id of this item in the database -	CreatedAt              time.Time    `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item created -	UpdatedAt              time.Time    `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item last updated -	Email                  string       `validate:"required_with=ConfirmedAt" bun:",nullzero,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:"type:timestamp,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:"type:timestamp,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:"min=0" bun:",notnull,default:0"`                                    // How many times has this user signed in? -	InviteID               string       `validate:"omitempty,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:"omitempty,ulid" bun:"type:CHAR(26),nullzero"`                       // 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:"type:timestamp,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:"type:timestamp,nullzero"`     // When did we send email confirmation to this user? -	ConfirmedAt            time.Time    `validate:"required_with=Email" bun:"type:timestamp,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:",notnull,default:false"`                                    // Is this user a moderator? -	Admin                  bool         `validate:"-" bun:",notnull,default:false"`                                    // Is this user an admin? -	Disabled               bool         `validate:"-" bun:",notnull,default:false"`                                    // Is this user disabled from posting? -	Approved               bool         `validate:"-" bun:",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:"type:timestamp,nullzero"`    // When did we email the user their reset-password email? +	ID                     string       `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`        // id of this item in the database +	CreatedAt              time.Time    `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item created +	UpdatedAt              time.Time    `validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item last updated +	Email                  string       `validate:"required_with=ConfirmedAt" bun:",nullzero,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:"type:timestamptz,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:"type:timestamptz,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:"min=0" bun:",notnull,default:0"`                                      // How many times has this user signed in? +	InviteID               string       `validate:"omitempty,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:"omitempty,ulid" bun:"type:CHAR(26),nullzero"`                         // 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:"type:timestamptz,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:"type:timestamptz,nullzero"`     // When did we send email confirmation to this user? +	ConfirmedAt            time.Time    `validate:"required_with=Email" bun:"type:timestamptz,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:",notnull,default:false"`                                      // Is this user a moderator? +	Admin                  bool         `validate:"-" bun:",notnull,default:false"`                                      // Is this user an admin? +	Disabled               bool         `validate:"-" bun:",notnull,default:false"`                                      // Is this user disabled from posting? +	Approved               bool         `validate:"-" bun:",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:"type:timestamptz,nullzero"`    // When did we email the user their reset-password email?  }  | 
