mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 12:12:24 -05:00
more work on struct validation
This commit is contained in:
parent
dc2e1bf9ab
commit
356d28fef9
12 changed files with 640 additions and 202 deletions
|
|
@ -24,43 +24,43 @@ 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:"required" bun:",nullzero,notnull,default:current_timestamp"` // when was item created
|
||||
UpdatedAt time.Time `validate:"required" bun:",nullzero,notnull,default:current_timestamp"` // when was item last updated
|
||||
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:",nullzero"` // content of this status; likely html-formatted but not guaranteed
|
||||
AttachmentIDs []string `validate:"dive,required,ulid" bun:"attachments,array,nullzero"` // Database IDs of any media attachments associated with this status
|
||||
Attachments []*MediaAttachment `validate:"-" bun:"attached_media,rel:has-many"` // Attachments corresponding to attachmentIDs
|
||||
TagIDs []string `validate:"dive,required,ulid" bun:"tags,array,nullzero"` // Database IDs of any tags used in this status
|
||||
Tags []*Tag `validate:"-" bun:"attached_tags,m2m:status_to_tags"` // Tags corresponding to tagIDs. https://bun.uptrace.dev/guide/relations.html#many-to-many-relation
|
||||
MentionIDs []string `validate:"dive,required,ulid" bun:"mentions,array,nullzero"` // Database IDs of any mentions in this status
|
||||
Mentions []*Mention `validate:"-" bun:"attached_mentions,rel:has-many"` // Mentions corresponding to mentionIDs
|
||||
EmojiIDs []string `validate:"dive,required,ulid" bun:"emojis,array,nullzero"` // Database IDs of any emojis used in this status
|
||||
Emojis []*Emoji `validate:"-" bun:"attached_emojis,m2m:status_to_emojis"` // Emojis corresponding to emojiIDs. https://bun.uptrace.dev/guide/relations.html#many-to-many-relation
|
||||
Local bool `validate:"-" bun:",nullzero,notnull,default:false"` // is this status from a local account?
|
||||
AccountID string `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"` // which account posted this status?
|
||||
Account *Account `validate:"-" bun:"rel:belongs-to"` // account corresponding to accountID
|
||||
AccountURI string `validate:"required,url" bun:",nullzero,notnull"` // activitypub uri of the owner of this status
|
||||
InReplyToID string `validate:"ulid,required_with=InReplyToURI InReplyToAccountID" bun:"type:CHAR(26),nullzero"` // id of the status this status replies to
|
||||
InReplyToURI string `validate:"required_with=InReplyToID InReplyToAccountID" bun:",nullzero"` // activitypub uri of the status this status is a reply to
|
||||
InReplyToAccountID string `validate:"ulid,required_with=InReplyToID InReplyToURI" bun:"type:CHAR(26),nullzero"` // id of the account that this status replies to
|
||||
InReplyTo *Status `validate:"-" bun:"-"` // status corresponding to inReplyToID
|
||||
InReplyToAccount *Account `validate:"-" bun:"rel:belongs-to"` // account corresponding to inReplyToAccountID
|
||||
BoostOfID string `validate:"ulid,required_with=BoostOfAccountID" bun:"type:CHAR(26),nullzero"` // id of the status this status is a boost of
|
||||
BoostOfAccountID string `validate:"ulid,required_with=BoostOfID" bun:"type:CHAR(26),nullzero"` // id of the account that owns the boosted status
|
||||
BoostOf *Status `validate:"-" bun:"-"` // status that corresponds to boostOfID
|
||||
BoostOfAccount *Account `validate:"-" bun:"rel:belongs-to"` // account that corresponds to boostOfAccountID
|
||||
ContentWarning string `validate:"-" bun:",nullzero"` // cw string for this status
|
||||
Visibility Visibility `validate:"-" bun:",nullzero,notnull"` // visibility entry for this status
|
||||
Sensitive bool `validate:"-" bun:",nullzero,notnull,default:false"` // mark the status as sensitive?
|
||||
Language string `validate:"-" bun:",nullzero"` // what language is this status written in?
|
||||
CreatedWithApplicationID string `validate:"ulid,required_if=Local true" bun:"type:CHAR(26),nullzero"` // Which application was used to create this status?
|
||||
CreatedWithApplication *Application `validate:"-" bun:"rel:belongs-to"` // application corresponding to createdWithApplicationID
|
||||
VisibilityAdvanced VisibilityAdvanced `validate:"required" bun:",nullzero,notnull" ` // advanced visibility for this status
|
||||
ActivityStreamsType string `validate:"required" bun:",nullzero,notnull"` // What is the activitystreams type of this status? See: https://www.w3.org/TR/activitystreams-vocabulary/#object-types. Will probably almost always be Note but who knows!.
|
||||
Text string `validate:"-" bun:",nullzero"` // Original text of the status without formatting
|
||||
Pinned bool `validate:"-" bun:",nullzero,notnull,default:false" ` // Has this status been pinned by its owner?
|
||||
ID string `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"` // id of this item in the database
|
||||
CreatedAt time.Time `validate:"required" bun:",nullzero,notnull,default:current_timestamp"` // when was item created
|
||||
UpdatedAt time.Time `validate:"required" bun:",nullzero,notnull,default:current_timestamp"` // when was item last updated
|
||||
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:",nullzero"` // content of this status; likely html-formatted but not guaranteed
|
||||
AttachmentIDs []string `validate:"dive,ulid" bun:"attachments,array,nullzero"` // Database IDs of any media attachments associated with this status
|
||||
Attachments []*MediaAttachment `validate:"-" bun:"attached_media,rel:has-many"` // Attachments corresponding to attachmentIDs
|
||||
TagIDs []string `validate:"dive,ulid" bun:"tags,array,nullzero"` // Database IDs of any tags used in this status
|
||||
Tags []*Tag `validate:"-" bun:"attached_tags,m2m:status_to_tags"` // Tags corresponding to tagIDs. https://bun.uptrace.dev/guide/relations.html#many-to-many-relation
|
||||
MentionIDs []string `validate:"dive,ulid" bun:"mentions,array,nullzero"` // Database IDs of any mentions in this status
|
||||
Mentions []*Mention `validate:"-" bun:"attached_mentions,rel:has-many"` // Mentions corresponding to mentionIDs
|
||||
EmojiIDs []string `validate:"dive,ulid" bun:"emojis,array,nullzero"` // Database IDs of any emojis used in this status
|
||||
Emojis []*Emoji `validate:"-" bun:"attached_emojis,m2m:status_to_emojis"` // Emojis corresponding to emojiIDs. https://bun.uptrace.dev/guide/relations.html#many-to-many-relation
|
||||
Local bool `validate:"-" bun:",notnull,default:false"` // is this status from a local account?
|
||||
AccountID string `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"` // which account posted this status?
|
||||
Account *Account `validate:"-" bun:"rel:belongs-to"` // account corresponding to accountID
|
||||
AccountURI string `validate:"required,url" bun:",nullzero,notnull"` // activitypub uri of the owner of this status
|
||||
InReplyToID string `validate:"required_with=InReplyToURI InReplyToAccountID,omitempty,ulid" bun:"type:CHAR(26),nullzero"` // id of the status this status replies to
|
||||
InReplyToURI string `validate:"required_with=InReplyToID InReplyToAccountID,omitempty,url" bun:",nullzero"` // activitypub uri of the status this status is a reply to
|
||||
InReplyToAccountID string `validate:"required_with=InReplyToID InReplyToURI,omitempty,ulid" bun:"type:CHAR(26),nullzero"` // id of the account that this status replies to
|
||||
InReplyTo *Status `validate:"-" bun:"-"` // status corresponding to inReplyToID
|
||||
InReplyToAccount *Account `validate:"-" bun:"rel:belongs-to"` // account corresponding to inReplyToAccountID
|
||||
BoostOfID string `validate:"required_with=BoostOfAccountID,omitempty,ulid" bun:"type:CHAR(26),nullzero"` // id of the status this status is a boost of
|
||||
BoostOfAccountID string `validate:"required_with=BoostOfID,omitempty,ulid" bun:"type:CHAR(26),nullzero"` // id of the account that owns the boosted status
|
||||
BoostOf *Status `validate:"-" bun:"-"` // status that corresponds to boostOfID
|
||||
BoostOfAccount *Account `validate:"-" bun:"rel:belongs-to"` // account that corresponds to boostOfAccountID
|
||||
ContentWarning string `validate:"-" bun:",nullzero"` // cw string for this status
|
||||
Visibility Visibility `validate:"-" bun:",nullzero,notnull"` // visibility entry for this status
|
||||
Sensitive bool `validate:"-" bun:",notnull,default:false"` // mark the status as sensitive?
|
||||
Language string `validate:"-" bun:",nullzero"` // what language is this status written in?
|
||||
CreatedWithApplicationID string `validate:"required_if=Local true,omitempty,ulid" bun:"type:CHAR(26),nullzero"` // Which application was used to create this status?
|
||||
CreatedWithApplication *Application `validate:"-" bun:"rel:belongs-to"` // application corresponding to createdWithApplicationID
|
||||
VisibilityAdvanced VisibilityAdvanced `validate:"required" bun:",nullzero,notnull" ` // advanced visibility for this status
|
||||
ActivityStreamsType string `validate:"required" bun:",nullzero,notnull"` // What is the activitystreams type of this status? See: https://www.w3.org/TR/activitystreams-vocabulary/#object-types. Will probably almost always be Note but who knows!.
|
||||
Text string `validate:"-" bun:",nullzero"` // Original text of the status without formatting
|
||||
Pinned bool `validate:"-" bun:",notnull,default:false" ` // Has this status been pinned by its owner?
|
||||
}
|
||||
|
||||
// StatusToTag is an intermediate struct to facilitate the many2many relationship between a status and one or more tags.
|
||||
|
|
@ -109,8 +109,8 @@ const (
|
|||
//
|
||||
// If DIRECT is selected, boostable will be FALSE, and all other flags will be TRUE.
|
||||
type VisibilityAdvanced struct {
|
||||
Federated bool `validate:"-" bun:",nullzero,notnull,default:true"` // This status will be federated beyond the local timeline(s)
|
||||
Boostable bool `validate:"-" bun:",nullzero,notnull,default:true"` // This status can be boosted/reblogged
|
||||
Replyable bool `validate:"-" bun:",nullzero,notnull,default:true"` // This status can be replied to
|
||||
Likeable bool `validate:"-" bun:",nullzero,notnull,default:true"` // This status can be liked/faved
|
||||
Federated bool `validate:"-" bun:",notnull,default:true"` // This status will be federated beyond the local timeline(s)
|
||||
Boostable bool `validate:"-" bun:",notnull,default:true"` // This status can be boosted/reblogged
|
||||
Replyable bool `validate:"-" bun:",notnull,default:true"` // This status can be replied to
|
||||
Likeable bool `validate:"-" bun:",notnull,default:true"` // This status can be liked/faved
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue