commit fffff93b754794c9709413adb2d016c6245f205e
parent 356d28fef9167ba1ec37ecc1a547196e78e56089
Author: tsmethurst <tobi.smethurst@protonmail.com>
Date: Mon, 30 Aug 2021 20:21:04 +0200
go fmt
Diffstat:
4 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/internal/gtsmodel/mediaattachment.go b/internal/gtsmodel/mediaattachment.go
@@ -25,24 +25,24 @@ import (
// MediaAttachment represents a user-uploaded media attachment: an image/video/audio/gif that is
// 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:"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
- 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)
- Type FileType `validate:"oneof=Image Gif Audio Video Unknown" bun:",notnull"` // Type of file (image/gif/audio/video)
- FileMeta FileMeta `validate:"required" bun:",nullzero,notnull"` // Metadata about the file
- AccountID string `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"` // To which account does this attachment belong
- Account *Account `validate:"-" bun:"rel:has-one"` // Account corresponding to accountID
- Description string `validate:"-" bun:",nullzero"` // Description of the attachment (for screenreaders)
- ScheduledStatusID string `validate:"omitempty,ulid" bun:"type:CHAR(26),nullzero"` // To which scheduled status does this attachment belong
+ 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
+ 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)
+ Type FileType `validate:"oneof=Image Gif Audio Video Unknown" bun:",notnull"` // Type of file (image/gif/audio/video)
+ FileMeta FileMeta `validate:"required" bun:",nullzero,notnull"` // Metadata about the file
+ AccountID string `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"` // To which account does this attachment belong
+ Account *Account `validate:"-" bun:"rel:has-one"` // Account corresponding to accountID
+ Description string `validate:"-" bun:",nullzero"` // Description of the attachment (for screenreaders)
+ ScheduledStatusID string `validate:"omitempty,ulid" bun:"type:CHAR(26),nullzero"` // To which scheduled status does this attachment belong
Blurhash string `validate:"required_if=Type Image,required_if=Type Gif,required_if=Type Video" bun:",nullzero"` // What is the generated blurhash of this attachment
- 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:",notnull,nullzero"` // metadata for the whole file
- Thumbnail Thumbnail `validate:"required" bun:",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?
+ 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:",notnull,nullzero"` // metadata for the whole file
+ Thumbnail Thumbnail `validate:"required" bun:",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?
}
// File refers to the metadata for the whole file
diff --git a/internal/gtsmodel/notification.go b/internal/gtsmodel/notification.go
@@ -31,7 +31,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:",notnull,default:false"` // Notification has been seen/read
}
// NotificationType describes the reason/type of this notification.
diff --git a/internal/gtsmodel/routersession_test.go b/internal/gtsmodel/routersession_test.go
@@ -46,7 +46,7 @@ func (suite *RouterSessionValidateTestSuite) TestValidateRouterSessionHappyPath(
func (suite *RouterSessionValidateTestSuite) TestValidateRouterSessionAuth() {
r := happyRouterSession()
-
+
// remove auth struct
r.Auth = nil
err := gtsmodel.ValidateStruct(*r)
@@ -65,7 +65,7 @@ func (suite *RouterSessionValidateTestSuite) TestValidateRouterSessionAuth() {
func (suite *RouterSessionValidateTestSuite) TestValidateRouterSessionCrypt() {
r := happyRouterSession()
-
+
// remove crypt struct
r.Crypt = nil
err := gtsmodel.ValidateStruct(*r)
diff --git a/internal/util/regexes.go b/internal/util/regexes.go
@@ -90,7 +90,7 @@ var (
followPathRegex = regexp.MustCompile(followPathRegexString)
ulidRegexString = `[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}`
- ulidRegex = regexp.MustCompile(fmt.Sprintf(`^%s$`, ulidRegexString))
+ ulidRegex = regexp.MustCompile(fmt.Sprintf(`^%s$`, ulidRegexString))
likedPathRegexString = fmt.Sprintf(`^/?%s/(%s)/%s$`, UsersPath, usernameRegexString, LikedPath)
// likedPathRegex parses a path that validates and captures the username part from eg /users/example_username/liked