summaryrefslogtreecommitdiff
path: root/internal/gtsmodel
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-08-15 12:35:05 +0200
committerLibravatar GitHub <noreply@github.com>2022-08-15 11:35:05 +0100
commitac6ed3d939fe9dad81aadbd04541e905c625ca82 (patch)
tree6116baf25675837dc99f69c49b9fec2ff112ce5c /internal/gtsmodel
parent[frontend] Sensitive media spoilers (#752) (diff)
downloadgotosocial-ac6ed3d939fe9dad81aadbd04541e905c625ca82.tar.xz
[chore] Update bun / sqlite versions; update gtsmodels (#754)
* upstep bun and sqlite versions * allow specific columns to be updated in the db * only update necessary columns for user * bit tidier * only update necessary fields of media_attachment * only update relevant instance fields * update tests * update only specific account columns * use bool pointers on gtsmodels includes attachment, status, account, user * update columns more selectively * test all default fields on new account insert * updating remaining bools on gtsmodels * initialize pointer fields when extracting AP emoji * copy bools properly * add copyBoolPtr convenience function + test it * initialize false bool ptrs a bit more neatly
Diffstat (limited to 'internal/gtsmodel')
-rw-r--r--internal/gtsmodel/account.go12
-rw-r--r--internal/gtsmodel/domainblock.go2
-rw-r--r--internal/gtsmodel/emoji.go4
-rw-r--r--internal/gtsmodel/follow.go4
-rw-r--r--internal/gtsmodel/followrequest.go4
-rw-r--r--internal/gtsmodel/mediaattachment.go6
-rw-r--r--internal/gtsmodel/mention.go2
-rw-r--r--internal/gtsmodel/notification.go2
-rw-r--r--internal/gtsmodel/status.go14
-rw-r--r--internal/gtsmodel/tag.go4
-rw-r--r--internal/gtsmodel/user.go8
11 files changed, 31 insertions, 31 deletions
diff --git a/internal/gtsmodel/account.go b/internal/gtsmodel/account.go
index 9dcb7bd5b..49db7dbda 100644
--- a/internal/gtsmodel/account.go
+++ b/internal/gtsmodel/account.go
@@ -44,15 +44,15 @@ type Account struct {
Fields []Field `validate:"-"` // a key/value map of fields that this account has added to their profile
Note string `validate:"-" bun:""` // A note that this account has on their profile (ie., the account's bio/description of themselves)
NoteRaw string `validate:"-" bun:""` // The raw contents of .Note without conversion to HTML, only available when requester = target
- Memorial bool `validate:"-" bun:",default:false"` // Is this a memorial account, ie., has the user passed away?
+ Memorial *bool `validate:"-" bun:",default:false"` // Is this a memorial account, ie., has the user passed away?
AlsoKnownAs string `validate:"omitempty,ulid" bun:"type:CHAR(26),nullzero"` // This account is associated with x account id (TODO: migrate to be AlsoKnownAsID)
MovedToAccountID string `validate:"omitempty,ulid" bun:"type:CHAR(26),nullzero"` // This account has moved this account id in the database
- Bot bool `validate:"-" bun:",default:false"` // Does this account identify itself as a bot?
+ Bot *bool `validate:"-" bun:",default:false"` // Does this account identify itself as a bot?
Reason string `validate:"-" bun:""` // What reason was given for signing up when this account was created?
- Locked bool `validate:"-" bun:",default:true"` // Does this account need an approval for new followers?
- Discoverable bool `validate:"-" bun:",default:false"` // Should this account be shown in the instance's profile directory?
+ Locked *bool `validate:"-" bun:",default:true"` // Does this account need an approval for new followers?
+ 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?
+ Sensitive *bool `validate:"-" bun:",default:false"` // Set posts from this account to sensitive by default?
Language string `validate:"omitempty,bcp47_language_tag" bun:",nullzero,notnull,default:'en'"` // What language does this account post in?
StatusFormat string `validate:"required_without=Domain,omitempty,oneof=plain markdown" bun:",nullzero"` // What is the default format for statuses posted by this account (only for local accounts).
URI string `validate:"required,url" bun:",nullzero,notnull,unique"` // ActivityPub URI for this account.
@@ -70,7 +70,7 @@ type Account struct {
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
+ 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/domainblock.go b/internal/gtsmodel/domainblock.go
index 5782b851d..000298aa9 100644
--- a/internal/gtsmodel/domainblock.go
+++ b/internal/gtsmodel/domainblock.go
@@ -30,6 +30,6 @@ type DomainBlock struct {
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
+ Obfuscate *bool `validate:"-" bun:",nullzero,notnull,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 860eb46c8..3460cc63e 100644
--- a/internal/gtsmodel/emoji.go
+++ b/internal/gtsmodel/emoji.go
@@ -38,8 +38,8 @@ type Emoji struct {
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: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?
+ Disabled *bool `validate:"-" bun:",nullzero,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?
+ VisibleInPicker *bool `validate:"-" bun:",nullzero,notnull,default:true"` // Is this emoji visible in the admin emoji picker?
CategoryID string `validate:"omitempty,ulid" bun:"type:CHAR(26),nullzero"` // In which emoji category is this emoji visible?
}
diff --git a/internal/gtsmodel/follow.go b/internal/gtsmodel/follow.go
index 15f01cfd2..8f5a01d3b 100644
--- a/internal/gtsmodel/follow.go
+++ b/internal/gtsmodel/follow.go
@@ -30,6 +30,6 @@ type Follow struct {
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?
+ ShowReblogs *bool `validate:"-" bun:",nullzero,notnull,default:true"` // Does this follow also want to see reblogs and not just posts?
+ Notify *bool `validate:"-" bun:",nullzero,notnull,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 4f7c8b807..b6c49a6ec 100644
--- a/internal/gtsmodel/followrequest.go
+++ b/internal/gtsmodel/followrequest.go
@@ -30,6 +30,6 @@ type FollowRequest struct {
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?
+ ShowReblogs *bool `validate:"-" bun:",nullzero,notnull,default:true"` // Does this follow also want to see reblogs and not just posts?
+ Notify *bool `validate:"-" bun:",nullzero,notnull,default:false"` // does the following account want to be notified when the followed account posts?
}
diff --git a/internal/gtsmodel/mediaattachment.go b/internal/gtsmodel/mediaattachment.go
index 2cd287eea..8fe8e2ca6 100644
--- a/internal/gtsmodel/mediaattachment.go
+++ b/internal/gtsmodel/mediaattachment.go
@@ -41,9 +41,9 @@ type MediaAttachment struct {
Processing ProcessingStatus `validate:"oneof=0 1 2 666" bun:",notnull,default:2"` // What is the processing status of this attachment
File File `validate:"required" bun:",embed:file_,notnull,nullzero"` // metadata for the whole file
Thumbnail Thumbnail `validate:"required" bun:",embed:thumbnail_,notnull,nullzero"` // small image thumbnail derived from a larger image, video, or audio file.
- Avatar bool `validate:"-" bun:",notnull,default:false"` // Is this attachment being used as an avatar?
- Header bool `validate:"-" bun:",notnull,default:false"` // Is this attachment being used as a header?
- Cached bool `validate:"-" bun:",notnull"` // Is this attachment currently cached by our instance?
+ Avatar *bool `validate:"-" bun:",nullzero,notnull,default:false"` // Is this attachment being used as an avatar?
+ Header *bool `validate:"-" bun:",nullzero,notnull,default:false"` // Is this attachment being used as a header?
+ Cached *bool `validate:"-" bun:",nullzero,notnull,default:false"` // Is this attachment currently cached by our instance?
}
// File refers to the metadata for the whole file
diff --git a/internal/gtsmodel/mention.go b/internal/gtsmodel/mention.go
index fd1d45622..dfc6cc3f4 100644
--- a/internal/gtsmodel/mention.go
+++ b/internal/gtsmodel/mention.go
@@ -35,7 +35,7 @@ type Mention struct {
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?
+ Silent *bool `validate:"-" bun:",nullzero,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 6a5ee06ef..d05898615 100644
--- a/internal/gtsmodel/notification.go
+++ b/internal/gtsmodel/notification.go
@@ -32,7 +32,7 @@ type Notification struct {
OriginAccount *Account `validate:"-" bun:"rel:belongs-to"` // Account corresponding to originAccountID
StatusID string `validate:"required_if=NotificationType mention,required_if=NotificationType reblog,required_if=NotificationType favourite,required_if=NotificationType status,omitempty,ulid" bun:"type:CHAR(26),nullzero"` // If the notification pertains to a status, what is the database ID of that status?
Status *Status `validate:"-" bun:"rel:belongs-to"` // Status corresponding to statusID
- Read bool `validate:"-" bun:",notnull,default:false"` // Notification has been seen/read
+ Read *bool `validate:"-" bun:",nullzero,notnull,default:false"` // Notification has been seen/read
}
// NotificationType describes the reason/type of this notification.
diff --git a/internal/gtsmodel/status.go b/internal/gtsmodel/status.go
index e798ea41b..1b4cc7174 100644
--- a/internal/gtsmodel/status.go
+++ b/internal/gtsmodel/status.go
@@ -38,7 +38,7 @@ type Status struct {
Mentions []*Mention `validate:"-" bun:"attached_mentions,rel:has-many"` // Mentions corresponding to mentionIDs
EmojiIDs []string `validate:"dive,ulid" bun:"emojis,array"` // 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?
+ 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
@@ -53,17 +53,17 @@ type Status struct {
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:"oneof=public unlocked followers_only mutuals_only direct" bun:",nullzero,notnull"` // visibility entry for this status
- Sensitive bool `validate:"-" bun:",notnull,default:false"` // mark the status as sensitive?
+ 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:"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
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:""` // Original text of the status without formatting
- Pinned bool `validate:"-" bun:",notnull,default:false"` // Has this status been pinned by its owner?
- Federated bool `validate:"-" bun:",notnull"` // This status will be federated beyond the local timeline(s)
- Boostable bool `validate:"-" bun:",notnull"` // This status can be boosted/reblogged
- Replyable bool `validate:"-" bun:",notnull"` // This status can be replied to
- Likeable bool `validate:"-" bun:",notnull"` // This status can be liked/faved
+ Pinned *bool `validate:"-" bun:",nullzero,notnull,default:false"` // Has this status been pinned by its owner?
+ Federated *bool `validate:"-" bun:",notnull"` // This status will be federated beyond the local timeline(s)
+ Boostable *bool `validate:"-" bun:",notnull"` // This status can be boosted/reblogged
+ Replyable *bool `validate:"-" bun:",notnull"` // This status can be replied to
+ Likeable *bool `validate:"-" bun:",notnull"` // This status can be liked/faved
}
/*
diff --git a/internal/gtsmodel/tag.go b/internal/gtsmodel/tag.go
index c73555311..09da27f3a 100644
--- a/internal/gtsmodel/tag.go
+++ b/internal/gtsmodel/tag.go
@@ -28,7 +28,7 @@ type Tag struct {
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?
+ Useable *bool `validate:"-" bun:",nullzero,notnull,default:true"` // can our instance users use this tag?
+ Listable *bool `validate:"-" bun:",nullzero,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/user.go b/internal/gtsmodel/user.go
index 929939572..0d108253a 100644
--- a/internal/gtsmodel/user.go
+++ b/internal/gtsmodel/user.go
@@ -50,10 +50,10 @@ type User struct {
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?
+ Moderator *bool `validate:"-" bun:",nullzero,notnull,default:false"` // Is this user a moderator?
+ Admin *bool `validate:"-" bun:",nullzero,notnull,default:false"` // Is this user an admin?
+ Disabled *bool `validate:"-" bun:",nullzero,notnull,default:false"` // Is this user disabled from posting?
+ Approved *bool `validate:"-" bun:",nullzero,notnull,default:false"` // Has this user been approved by a moderator?
ResetPasswordToken string `validate:"required_with=ResetPasswordSentAt" bun:",nullzero"` // The generated token that the user can use to reset their password
ResetPasswordSentAt time.Time `validate:"required_with=ResetPasswordToken" bun:"type:timestamptz,nullzero"` // When did we email the user their reset-password email?
}