From 0f990d07d51f09f000a13c79fa29f16d441b0fe9 Mon Sep 17 00:00:00 2001 From: "kim (grufwub)" Date: Thu, 9 Sep 2021 20:43:06 +0100 Subject: [PATCH] further database tag fixes Signed-off-by: kim (grufwub) --- internal/gtsmodel/account.go | 12 ++++++------ internal/gtsmodel/application.go | 4 ++-- internal/gtsmodel/block.go | 16 ++++++++-------- internal/gtsmodel/domainblock.go | 6 +++--- internal/gtsmodel/emoji.go | 2 +- internal/gtsmodel/follow.go | 20 ++++++++++---------- internal/gtsmodel/followrequest.go | 20 ++++++++++---------- internal/gtsmodel/instance.go | 10 +++++----- 8 files changed, 45 insertions(+), 45 deletions(-) diff --git a/internal/gtsmodel/account.go b/internal/gtsmodel/account.go index 879fd9d56..a51e6ed7c 100644 --- a/internal/gtsmodel/account.go +++ b/internal/gtsmodel/account.go @@ -32,11 +32,11 @@ type Account struct { ID string `validate:"required,ulid" bun:"type:CHAR(26),pk,notnull,unique"` // id of this item in the database CreatedAt time.Time `validate:"-" bun:"type:timestamp,notnull,default:current_timestamp"` // when was item created UpdatedAt time.Time `validate:"-" bun:"type:timestamp,notnull,default:current_timestamp"` // when was item last updated - Username string `validate:"required" bun:",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:",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. + 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 AvatarMediaAttachment *MediaAttachment `validate:"-" bun:"rel:belongs-to"` // MediaAttachment corresponding to avatarMediaAttachmentID - AvatarRemoteURL string `validate:"omitempty,url" bun:""` // For a non-local account, where can the header be fetched? + AvatarRemoteURL string `validate:"omitempty,url" bun:",nullzero"` // For a non-local account, where can the header be fetched? HeaderMediaAttachmentID string `validate:"omitempty,ulid" bun:"type:CHAR(26),nullzero"` // Database ID of the media attachment, if present HeaderMediaAttachment *MediaAttachment `validate:"-" bun:"rel:belongs-to"` // MediaAttachment corresponding to headerMediaAttachmentID HeaderRemoteURL string `validate:"omitempty,url" bun:",nullzero"` // For a non-local account, where can the header be fetched? @@ -52,9 +52,9 @@ type Account struct { Discoverable bool `validate:"-" bun:",default:false"` // Should this account be shown in the instance's profile directory? Privacy Visibility `validate:"required_without=Domain,omitempty,oneof=public unlocked followers_only mutuals_only direct" bun:",nullzero"` // Default post privacy for this account Sensitive bool `validate:"-" bun:",default:false"` // Set posts from this account to sensitive by default? - Language string `validate:"omitempty,bcp47_language_tag" bun:",notnull,default:'en'"` // What language does this account post in? - URI string `validate:"required,url" bun:",notnull,unique"` // ActivityPub URI for this account. - URL string `validate:"required_without=Domain,omitempty,url" bun:",unique"` // Web URL for this account's profile + 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. 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 diff --git a/internal/gtsmodel/application.go b/internal/gtsmodel/application.go index 7ec71ec2e..de37c8d61 100644 --- a/internal/gtsmodel/application.go +++ b/internal/gtsmodel/application.go @@ -26,10 +26,10 @@ 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:",nullzero,notnull"` // name of the application given when it was created (eg., 'tusky') + 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:",nullzero,notnull"` // scopes requested when this app was created + 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 2cc089e6b..778ac45be 100644 --- a/internal/gtsmodel/block.go +++ b/internal/gtsmodel/block.go @@ -22,12 +22,12 @@ 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 - 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"` // Who does this block originate from? - Account *Account `validate:"-" bun:"rel:belongs-to"` // Account corresponding to accountID - TargetAccountID string `validate:"required,ulid" bun:"type:CHAR(26),unique:blocksrctarget,notnull"` // Who is the target of this block ? - TargetAccount *Account `validate:"-" bun:"rel:belongs-to"` // Account corresponding to targetAccountID + 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 + 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 + TargetAccountID string `validate:"required,ulid" bun:"type:CHAR(26),unique:blocksrctarget,notnull,nullzero"` // Who is the target of this block ? + TargetAccount *Account `validate:"-" bun:"rel:belongs-to"` // Account corresponding to targetAccountID } diff --git a/internal/gtsmodel/domainblock.go b/internal/gtsmodel/domainblock.go index 4c72b842a..8490b45bf 100644 --- a/internal/gtsmodel/domainblock.go +++ b/internal/gtsmodel/domainblock.go @@ -28,8 +28,8 @@ type DomainBlock struct { 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:",nullzero"` // Private comment on this block, viewable to admins - PublicComment string `validate:"-" bun:",nullzero"` // Public comment on this block, viewable (optionally) by everyone - Obfuscate bool `validate:"-" bun:",nullzero,default:false"` // whether the domain name should appear obfuscated when displaying it publicly + 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/emoji.go b/internal/gtsmodel/emoji.go index 93c43c0f7..ac9f753fc 100644 --- a/internal/gtsmodel/emoji.go +++ b/internal/gtsmodel/emoji.go @@ -25,7 +25,7 @@ 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 - Shortcode string `validate:"required" bun:",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. + 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. ImageStaticRemoteURL string `validate:"required_without=ImageStaticURL,omitempty,url" bun:",nullzero"` // Where can a static / non-animated version of this emoji be retrieved remotely? Null for local emojis. diff --git a/internal/gtsmodel/follow.go b/internal/gtsmodel/follow.go index 8c4617f48..b5908277d 100644 --- a/internal/gtsmodel/follow.go +++ b/internal/gtsmodel/follow.go @@ -22,14 +22,14 @@ 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 - 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"` // Who does this follow originate from? - Account *Account `validate:"-" bun:"rel:belongs-to"` // Account corresponding to accountID - TargetAccountID string `validate:"required,ulid" bun:"type:CHAR(26),unique:srctarget,notnull"` // Who is the target of this follow ? - TargetAccount *Account `validate:"-" bun:"rel:belongs-to"` // Account corresponding to targetAccountID - ShowReblogs bool `validate:"-" bun:",nullzero,default:true"` // Does this follow also want to see reblogs and not just posts? - Notify bool `validate:"-" bun:",nullzero,default:false"` // does the following account want to be notified when the followed account posts? + 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 + 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 + TargetAccountID string `validate:"required,ulid" bun:"type:CHAR(26),unique:srctarget,notnull,nullzero"` // Who is the target of this follow ? + TargetAccount *Account `validate:"-" bun:"rel:belongs-to"` // Account corresponding to targetAccountID + ShowReblogs bool `validate:"-" bun:",default:true"` // Does this follow also want to see reblogs and not just posts? + Notify bool `validate:"-" bun:",default:false"` // does the following account want to be notified when the followed account posts? } diff --git a/internal/gtsmodel/followrequest.go b/internal/gtsmodel/followrequest.go index 9ffdb5938..fe77d56f2 100644 --- a/internal/gtsmodel/followrequest.go +++ b/internal/gtsmodel/followrequest.go @@ -22,14 +22,14 @@ 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 - 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"` // Who does this follow request originate from? - Account *Account `validate:"-" bun:"rel:belongs-to"` // Account corresponding to accountID - TargetAccountID string `validate:"required,ulid" bun:"type:CHAR(26),unique:frsrctarget,notnull"` // Who is the target of this follow request? - TargetAccount *Account `validate:"-" bun:"rel:belongs-to"` // Account corresponding to targetAccountID - ShowReblogs bool `validate:"-" bun:",nullzero,default:true"` // Does this follow also want to see reblogs and not just posts? - Notify bool `validate:"-" bun:",nullzero,default:false"` // does the following account want to be notified when the followed account posts? + 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 + 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 + TargetAccountID string `validate:"required,ulid" bun:"type:CHAR(26),unique:frsrctarget,notnull,nullzero"` // Who is the target of this follow request? + TargetAccount *Account `validate:"-" bun:"rel:belongs-to"` // Account corresponding to targetAccountID + ShowReblogs bool `validate:"-" bun:",default:true"` // Does this follow also want to see reblogs and not just posts? + Notify bool `validate:"-" bun:",default:false"` // does the following account want to be notified when the followed account posts? } diff --git a/internal/gtsmodel/instance.go b/internal/gtsmodel/instance.go index a7cc8a034..4d8c5af3c 100644 --- a/internal/gtsmodel/instance.go +++ b/internal/gtsmodel/instance.go @@ -26,15 +26,15 @@ type Instance struct { 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,unique"` // Instance domain eg example.org - Title string `validate:"-" bun:",nullzero"` // Title of this instance as it would like to be displayed. + 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? 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:",nullzero"` // Short description of this instance - Description string `validate:"-" bun:",nullzero"` // Longer description of this instance - Terms string `validate:"-" bun:",nullzero"` // Terms and conditions of this instance - ContactEmail string `validate:"omitempty,email" bun:",nullzero"` // Contact email address for this instance + ShortDescription string `validate:"-" bun:""` // Short description of this instance + Description string `validate:"-" bun:""` // Longer description of this instance + Terms string `validate:"-" bun:""` // Terms and conditions of this instance + ContactEmail string `validate:"omitempty,email" bun:""` // Contact email address for this instance ContactAccountUsername string `validate:"required_with=ContactAccountID" bun:",nullzero"` // Username of the contact account for this instance ContactAccountID string `validate:"required_with=ContactAccountUsername,omitempty,ulid" bun:"type:CHAR(26),nullzero"` // Contact account ID in the database for this instance ContactAccount *Account `validate:"-" bun:"rel:belongs-to"` // account corresponding to contactAccountID