mirror of
1
Fork 0

more work on struct validation

This commit is contained in:
tsmethurst 2021-08-30 13:38:06 +02:00 committed by tsmethurst
parent 8ba816cd83
commit dc2e1bf9ab
14 changed files with 455 additions and 144 deletions

View File

@ -20,7 +20,7 @@ package gtsmodel
// RouterSession is used to store and retrieve settings for a router session. // RouterSession is used to store and retrieve settings for a router session.
type RouterSession struct { type RouterSession struct {
ID string `bun:"type:CHAR(26),pk,notnull"` ID string `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull"`
Auth []byte `bun:"type:bytea,notnull,nullzero"` Auth []byte `validate:"required,len=32" bun:"type:bytea,notnull,nullzero"`
Crypt []byte `bun:"type:bytea,notnull,nullzero"` Crypt []byte `validate:"required,len=32" bun:"type:bytea,notnull,nullzero"`
} }

View File

@ -24,87 +24,59 @@ import (
// Status represents a user-created 'post' or 'status' in the database, either remote or local // Status represents a user-created 'post' or 'status' in the database, either remote or local
type Status struct { type Status struct {
// id of the status in the database ID string `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"` // id of this item in the database
ID string `bun:"type:CHAR(26),pk,notnull"` CreatedAt time.Time `validate:"required" bun:",nullzero,notnull,default:current_timestamp"` // when was item created
// uri at which this status is reachable UpdatedAt time.Time `validate:"required" bun:",nullzero,notnull,default:current_timestamp"` // when was item last updated
URI string `bun:",unique,nullzero"` URI string `validate:"required,url" bun:",unique,nullzero,notnull"` // activitypub URI of this status
// web url for viewing this status URL string `validate:"url" bun:",nullzero"` // web url for viewing this status
URL string `bun:",unique,nullzero"` Content string `validate:"-" bun:",nullzero"` // content of this status; likely html-formatted but not guaranteed
// the html-formatted content of this status AttachmentIDs []string `validate:"dive,required,ulid" bun:"attachments,array,nullzero"` // Database IDs of any media attachments associated with this status
Content string `bun:",nullzero"` Attachments []*MediaAttachment `validate:"-" bun:"attached_media,rel:has-many"` // Attachments corresponding to attachmentIDs
// Database IDs of any media attachments associated with this status TagIDs []string `validate:"dive,required,ulid" bun:"tags,array,nullzero"` // Database IDs of any tags used in this status
AttachmentIDs []string `bun:"attachments,array"` 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
Attachments []*MediaAttachment `bun:"attached_media,rel:has-many"` MentionIDs []string `validate:"dive,required,ulid" bun:"mentions,array,nullzero"` // Database IDs of any mentions in this status
// Database IDs of any tags used in this status Mentions []*Mention `validate:"-" bun:"attached_mentions,rel:has-many"` // Mentions corresponding to mentionIDs
TagIDs []string `bun:"tags,array"` EmojiIDs []string `validate:"dive,required,ulid" bun:"emojis,array,nullzero"` // Database IDs of any emojis used in this status
Tags []*Tag `bun:"attached_tags,m2m:status_to_tags"` // https://bun.uptrace.dev/guide/relations.html#many-to-many-relation 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
// Database IDs of any mentions in this status Local bool `validate:"-" bun:",nullzero,notnull,default:false"` // is this status from a local account?
MentionIDs []string `bun:"mentions,array"` AccountID string `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"` // which account posted this status?
Mentions []*Mention `bun:"attached_mentions,rel:has-many"` Account *Account `validate:"-" bun:"rel:belongs-to"` // account corresponding to accountID
// Database IDs of any emojis used in this status AccountURI string `validate:"required,url" bun:",nullzero,notnull"` // activitypub uri of the owner of this status
EmojiIDs []string `bun:"emojis,array"` InReplyToID string `validate:"ulid,required_with=InReplyToURI InReplyToAccountID" bun:"type:CHAR(26),nullzero"` // id of the status this status replies to
Emojis []*Emoji `bun:"attached_emojis,m2m:status_to_emojis"` // https://bun.uptrace.dev/guide/relations.html#many-to-many-relation InReplyToURI string `validate:"required_with=InReplyToID InReplyToAccountID" bun:",nullzero"` // activitypub uri of the status this status is a reply to
// when was this status created? InReplyToAccountID string `validate:"ulid,required_with=InReplyToID InReplyToURI" bun:"type:CHAR(26),nullzero"` // id of the account that this status replies to
CreatedAt time.Time `bun:",notnull,nullzero,default:current_timestamp"` InReplyTo *Status `validate:"-" bun:"-"` // status corresponding to inReplyToID
// when was this status updated? InReplyToAccount *Account `validate:"-" bun:"rel:belongs-to"` // account corresponding to inReplyToAccountID
UpdatedAt time.Time `bun:",notnull,nullzero,default:current_timestamp"` BoostOfID string `validate:"ulid,required_with=BoostOfAccountID" bun:"type:CHAR(26),nullzero"` // id of the status this status is a boost of
// is this status from a local account? BoostOfAccountID string `validate:"ulid,required_with=BoostOfID" bun:"type:CHAR(26),nullzero"` // id of the account that owns the boosted status
Local bool BoostOf *Status `validate:"-" bun:"-"` // status that corresponds to boostOfID
// which account posted this status? BoostOfAccount *Account `validate:"-" bun:"rel:belongs-to"` // account that corresponds to boostOfAccountID
AccountID string `bun:"type:CHAR(26),notnull"` ContentWarning string `validate:"-" bun:",nullzero"` // cw string for this status
Account *Account `bun:"rel:belongs-to"` Visibility Visibility `validate:"-" bun:",nullzero,notnull"` // visibility entry for this status
// AP uri of the owner of this status Sensitive bool `validate:"-" bun:",nullzero,notnull,default:false"` // mark the status as sensitive?
AccountURI string `bun:",nullzero"` Language string `validate:"-" bun:",nullzero"` // what language is this status written in?
// id of the status this status is a reply to CreatedWithApplicationID string `validate:"ulid,required_if=Local true" bun:"type:CHAR(26),nullzero"` // Which application was used to create this status?
InReplyToID string `bun:"type:CHAR(26),nullzero"` CreatedWithApplication *Application `validate:"-" bun:"rel:belongs-to"` // application corresponding to createdWithApplicationID
InReplyTo *Status `bun:"-"` VisibilityAdvanced VisibilityAdvanced `validate:"required" bun:",nullzero,notnull" ` // advanced visibility for this status
// AP uri of the status this status is a reply to 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!.
InReplyToURI string `bun:",nullzero"` Text string `validate:"-" bun:",nullzero"` // Original text of the status without formatting
// id of the account that this status replies to Pinned bool `validate:"-" bun:",nullzero,notnull,default:false" ` // Has this status been pinned by its owner?
InReplyToAccountID string `bun:"type:CHAR(26),nullzero"`
InReplyToAccount *Account `bun:"rel:belongs-to"`
// id of the status this status is a boost of
BoostOfID string `bun:"type:CHAR(26),nullzero"`
BoostOf *Status `bun:"-"`
// id of the account that owns the boosted status
BoostOfAccountID string `bun:"type:CHAR(26),nullzero"`
BoostOfAccount *Account `bun:"rel:belongs-to"`
// cw string for this status
ContentWarning string `bun:",nullzero"`
// visibility entry for this status
Visibility Visibility `bun:",notnull"`
// mark the status as sensitive?
Sensitive bool
// what language is this status written in?
Language string `bun:",nullzero"`
// Which application was used to create this status?
CreatedWithApplicationID string `bun:"type:CHAR(26),nullzero"`
CreatedWithApplication *Application `bun:"rel:belongs-to"`
// advanced visibility for this status
VisibilityAdvanced *VisibilityAdvanced
// 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!.
ActivityStreamsType string `bun:",nullzero"`
// Original text of the status without formatting
Text string `bun:",nullzero"`
// Has this status been pinned by its owner?
Pinned bool
} }
// StatusToTag is an intermediate struct to facilitate the many2many relationship between a status and one or more tags. // StatusToTag is an intermediate struct to facilitate the many2many relationship between a status and one or more tags.
type StatusToTag struct { type StatusToTag struct {
StatusID string `bun:"type:CHAR(26),unique:statustag,nullzero"` StatusID string `validate:"ulid,required" bun:"type:CHAR(26),unique:statustag,nullzero,notnull"`
Status *Status `bun:"rel:belongs-to"` Status *Status `validate:"-" bun:"rel:belongs-to"`
TagID string `bun:"type:CHAR(26),unique:statustag,nullzero"` TagID string `validate:"ulid,required" bun:"type:CHAR(26),unique:statustag,nullzero,notnull"`
Tag *Tag `bun:"rel:belongs-to"` Tag *Tag `validate:"-" bun:"rel:belongs-to"`
} }
// StatusToEmoji is an intermediate struct to facilitate the many2many relationship between a status and one or more emojis. // StatusToEmoji is an intermediate struct to facilitate the many2many relationship between a status and one or more emojis.
type StatusToEmoji struct { type StatusToEmoji struct {
StatusID string `bun:"type:CHAR(26),unique:statusemoji,nullzero"` StatusID string `validate:"ulid,required" bun:"type:CHAR(26),unique:statusemoji,nullzero,notnull"`
Status *Status `bun:"rel:belongs-to"` Status *Status `validate:"-" bun:"rel:belongs-to"`
EmojiID string `bun:"type:CHAR(26),unique:statusemoji,nullzero"` EmojiID string `validate:"ulid,required" bun:"type:CHAR(26),unique:statusemoji,nullzero,notnull"`
Emoji *Emoji `bun:"rel:belongs-to"` Emoji *Emoji `validate:"-" bun:"rel:belongs-to"`
} }
// Visibility represents the visibility granularity of a status. // Visibility represents the visibility granularity of a status.
@ -137,12 +109,8 @@ const (
// //
// If DIRECT is selected, boostable will be FALSE, and all other flags will be TRUE. // If DIRECT is selected, boostable will be FALSE, and all other flags will be TRUE.
type VisibilityAdvanced struct { type VisibilityAdvanced struct {
// This status will be federated beyond the local timeline(s) Federated bool `validate:"-" bun:",nullzero,notnull,default:true"` // This status will be federated beyond the local timeline(s)
Federated bool `bun:"default:true"` Boostable bool `validate:"-" bun:",nullzero,notnull,default:true"` // This status can be boosted/reblogged
// This status can be boosted/reblogged Replyable bool `validate:"-" bun:",nullzero,notnull,default:true"` // This status can be replied to
Boostable bool `bun:"default:true"` Likeable bool `validate:"-" bun:",nullzero,notnull,default:true"` // This status can be liked/faved
// This status can be replied to
Replyable bool `bun:"default:true"`
// This status can be liked/faved
Likeable bool `bun:"default:true"`
} }

View File

@ -0,0 +1,161 @@
/*
GoToSocial
Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gtsmodel_test
import (
"testing"
"time"
"github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
)
func happyStatus() *gtsmodel.Status {
return &gtsmodel.Status{
ID: "01FEBBH6NYDG87NK6A6EC543ED",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
URI: "https://example.org/users/test_user/statuses/01FEBBH6NYDG87NK6A6EC543ED",
URL: "https://example.org/@test_user/01FEBBH6NYDG87NK6A6EC543ED",
Content: "<p>Test status! #hello</p>",
AttachmentIDs: []string{"01FEBBKZBY9H5FEP3PHVVAAGN1", "01FEBBM7S2R4WT6WWW22KN1PWE"},
Attachments: nil,
TagIDs: []string{"01FEBBNBMBSN1FESMZ1TCXNWYP"},
Tags: nil,
MentionIDs: nil,
Mentions: nil,
EmojiIDs: nil,
Emojis: nil,
Local: true,
AccountID: "01FEBBQ4KEP3824WW61MF52638",
Account: nil,
AccountURI: "https://example.org/users/test_user",
InReplyToID: "",
InReplyToURI: "",
InReplyToAccountID: "",
InReplyTo: nil,
InReplyToAccount: nil,
BoostOfID: "",
BoostOfAccountID: "",
BoostOf: nil,
BoostOfAccount: nil,
ContentWarning: "hello world test post",
Visibility: gtsmodel.VisibilityPublic,
Sensitive: false,
Language: "en",
CreatedWithApplicationID: "01FEBBZHF4GFVRXSJVXD0JTZZ2",
CreatedWithApplication: nil,
VisibilityAdvanced: gtsmodel.VisibilityAdvanced{
Federated: true,
Boostable: true,
Replyable: true,
Likeable: true,
},
ActivityStreamsType: gtsmodel.ActivityStreamsNote,
Text: "Test status! #hello",
Pinned: false,
}
}
type StatusValidateTestSuite struct {
suite.Suite
}
func (suite *StatusValidateTestSuite) TestValidateStatusHappyPath() {
// no problem here
s := happyStatus()
err := gtsmodel.ValidateStruct(*s)
suite.NoError(err)
}
func (suite *StatusValidateTestSuite) TestValidateStatusBadID() {
s := happyStatus()
s.ID = ""
err := gtsmodel.ValidateStruct(*s)
suite.EqualError(err, "Key: 'Status.ID' Error:Field validation for 'ID' failed on the 'required' tag")
s.ID = "01FE96W293ZPRG9FQQP48HK8N001FE96W32AT24VYBGM12WN3GKB"
err = gtsmodel.ValidateStruct(*s)
suite.EqualError(err, "Key: 'Status.ID' Error:Field validation for 'ID' failed on the 'ulid' tag")
}
func (suite *StatusValidateTestSuite) TestValidateStatusAttachmentIDs() {
s := happyStatus()
s.AttachmentIDs[0] = ""
err := gtsmodel.ValidateStruct(*s)
suite.EqualError(err, "Key: 'Status.AttachmentIDs[0]' Error:Field validation for 'AttachmentIDs[0]' failed on the 'required' tag")
s.AttachmentIDs[0] = "01FE96W293ZPRG9FQQP48HK8N001FE96W32AT24VYBGM12WN3GKB"
err = gtsmodel.ValidateStruct(*s)
suite.EqualError(err, "Key: 'Status.AttachmentIDs[0]' Error:Field validation for 'AttachmentIDs[0]' failed on the 'ulid' tag")
s.AttachmentIDs[1] = ""
err = gtsmodel.ValidateStruct(*s)
suite.EqualError(err, "Key: 'Status.AttachmentIDs[0]' Error:Field validation for 'AttachmentIDs[0]' failed on the 'ulid' tag\nKey: 'Status.AttachmentIDs[1]' Error:Field validation for 'AttachmentIDs[1]' failed on the 'required' tag")
s.AttachmentIDs = []string{}
err = gtsmodel.ValidateStruct(*s)
suite.NoError(err)
s.AttachmentIDs = nil
err = gtsmodel.ValidateStruct(*s)
suite.NoError(err)
}
func (suite *StatusValidateTestSuite) TestStatusApplicationID() {
s := happyStatus()
s.CreatedWithApplicationID = ""
err := gtsmodel.ValidateStruct(*s)
suite.EqualError(err, "Key: 'Status.CreatedWithApplicationID' Error:Field validation for 'CreatedWithApplicationID' failed on the 'required_if' tag")
s.Local = false
err = gtsmodel.ValidateStruct(*s)
suite.NoError(err)
}
func (suite *StatusValidateTestSuite) TestValidateStatusReplyFields() {
s := happyStatus()
s.InReplyToAccountID = "01FEBCTP6DN7961PN81C3DVM4N "
err := gtsmodel.ValidateStruct(*s)
suite.EqualError(err, "Key: 'Status.InReplyToID' Error:Field validation for 'InReplyToID' failed on the 'required_with' tag\nKey: 'Status.InReplyToURI' Error:Field validation for 'InReplyToURI' failed on the 'required_with' tag\nKey: 'Status.InReplyToAccountID' Error:Field validation for 'InReplyToAccountID' failed on the 'ulid' tag")
s.InReplyToAccountID = "01FEBCTP6DN7961PN81C3DVM4N"
err = gtsmodel.ValidateStruct(*s)
suite.EqualError(err, "Key: 'Status.InReplyToID' Error:Field validation for 'InReplyToID' failed on the 'required_with' tag\nKey: 'Status.InReplyToURI' Error:Field validation for 'InReplyToURI' failed on the 'required_with' tag")
s.InReplyToURI = "https://example.org/users/mmbop/statuses/aaaaaaaa"
err = gtsmodel.ValidateStruct(*s)
suite.EqualError(err, "Key: 'Status.InReplyToID' Error:Field validation for 'InReplyToID' failed on the 'required_with' tag")
s.InReplyToID = "not a valid ulid"
err = gtsmodel.ValidateStruct(*s)
suite.EqualError(err, "Key: 'Status.InReplyToID' Error:Field validation for 'InReplyToID' failed on the 'ulid' tag")
s.InReplyToID = "01FEBD07E72DEY6YB9K10ZA6ST"
err = gtsmodel.ValidateStruct(*s)
suite.NoError(err)
}
func TestStatusValidateTestSuite(t *testing.T) {
suite.Run(t, new(StatusValidateTestSuite))
}

View File

@ -20,18 +20,14 @@ package gtsmodel
import "time" import "time"
// StatusBookmark refers to one account having a 'bookmark' of the status of another account // StatusBookmark refers to one account having a 'bookmark' of the status of another account.
type StatusBookmark struct { type StatusBookmark struct {
// id of this bookmark in the database ID string `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"` // id of this item in the database
ID string `bun:"type:CHAR(26),pk,notnull,unique"` CreatedAt time.Time `validate:"required" bun:",nullzero,notnull,default:current_timestamp"` // when was item created
// when was this bookmark created AccountID string `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"` // id of the account that created ('did') the bookmark
CreatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"` Account *Account `validate:"-" bun:"rel:belongs-to"` // account that created the bookmark
// id of the account that created ('did') the bookmarking TargetAccountID string `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"` // id the account owning the bookmarked status
AccountID string `bun:"type:CHAR(26),notnull"` TargetAccount *Account `validate:"-" bun:"rel:belongs-to"` // account owning the bookmarked status
Account *Account `bun:"rel:belongs-to"` StatusID string `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"` // database id of the status that has been bookmarked
// id the account owning the bookmarked status Status *Status `validate:"-" bun:"rel:belongs-to"` // the bookmarked status
TargetAccountID string `bun:"type:CHAR(26),notnull"`
TargetAccount *Account `bun:"rel:belongs-to"`
// database id of the status that has been bookmarked
StatusID string `bun:"type:CHAR(26),notnull"`
} }

View File

@ -0,0 +1,87 @@
/*
GoToSocial
Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gtsmodel_test
import (
"testing"
"time"
"github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
)
func happyStatusBookmark() *gtsmodel.StatusBookmark {
return &gtsmodel.StatusBookmark{
ID: "01FE91RJR88PSEEE30EV35QR8N",
CreatedAt: time.Now(),
AccountID: "01FE96MAE58MXCE5C4SSMEMCEK",
Account: nil,
TargetAccountID: "01FE96MXRHWZHKC0WH5FT82H1A",
TargetAccount: nil,
StatusID: "01FE96NBPNJNY26730FT6GZTFE",
Status: nil,
}
}
type StatusBookmarkValidateTestSuite struct {
suite.Suite
}
func (suite *StatusBookmarkValidateTestSuite) TestValidateStatusBookmarkHappyPath() {
// no problem here
m := happyStatusBookmark()
err := gtsmodel.ValidateStruct(*m)
suite.NoError(err)
}
func (suite *StatusBookmarkValidateTestSuite) TestValidateStatusBookmarkBadID() {
m := happyStatusBookmark()
m.ID = ""
err := gtsmodel.ValidateStruct(*m)
suite.EqualError(err, "Key: 'StatusBookmark.ID' Error:Field validation for 'ID' failed on the 'required' tag")
m.ID = "01FE96W293ZPRG9FQQP48HK8N001FE96W32AT24VYBGM12WN3GKB"
err = gtsmodel.ValidateStruct(*m)
suite.EqualError(err, "Key: 'StatusBookmark.ID' Error:Field validation for 'ID' failed on the 'ulid' tag")
}
func (suite *StatusBookmarkValidateTestSuite) TestValidateStatusBookmarkDodgyStatusID() {
m := happyStatusBookmark()
m.StatusID = "9HZJ76B6VXSKF"
err := gtsmodel.ValidateStruct(*m)
suite.EqualError(err, "Key: 'StatusBookmark.StatusID' Error:Field validation for 'StatusID' failed on the 'ulid' tag")
m.StatusID = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!!!!!!!!!!!!"
err = gtsmodel.ValidateStruct(*m)
suite.EqualError(err, "Key: 'StatusBookmark.StatusID' Error:Field validation for 'StatusID' failed on the 'ulid' tag")
}
func (suite *StatusBookmarkValidateTestSuite) TestValidateStatusBookmarkNoCreatedAt() {
m := happyStatusBookmark()
m.CreatedAt = time.Time{}
err := gtsmodel.ValidateStruct(*m)
suite.EqualError(err, "Key: 'StatusBookmark.CreatedAt' Error:Field validation for 'CreatedAt' failed on the 'required' tag")
}
func TestStatusBookmarkValidateTestSuite(t *testing.T) {
suite.Run(t, new(StatusBookmarkValidateTestSuite))
}

View File

@ -22,19 +22,13 @@ import "time"
// StatusFave refers to a 'fave' or 'like' in the database, from one account, targeting the status of another account // StatusFave refers to a 'fave' or 'like' in the database, from one account, targeting the status of another account
type StatusFave struct { type StatusFave struct {
// id of this fave in the database ID string `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"` // id of this item in the database
ID string `bun:"type:CHAR(26),pk,notnull,unique"` CreatedAt time.Time `validate:"required" bun:",nullzero,notnull,default:current_timestamp"` // when was item created
// when was this fave created AccountID string `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"` // id of the account that created ('did') the fave
CreatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"` Account *Account `validate:"-" bun:"rel:belongs-to"` // account that created the fave
// id of the account that created ('did') the fave TargetAccountID string `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"` // id the account owning the faved status
AccountID string `bun:"type:CHAR(26),notnull"` TargetAccount *Account `validate:"-" bun:"rel:belongs-to"` // account owning the faved status
Account *Account `bun:"rel:belongs-to"` StatusID string `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"` // database id of the status that has been 'faved'
// id the account owning the faved status Status *Status `validate:"-" bun:"rel:belongs-to"` // the faved status
TargetAccountID string `bun:"type:CHAR(26),notnull"` URI string `validate:"required,url" bun:",nullzero,notnull"` // ActivityPub URI of this fave
TargetAccount *Account `bun:"rel:belongs-to"`
// database id of the status that has been 'faved'
StatusID string `bun:"type:CHAR(26),notnull"`
Status *Status `bun:"rel:belongs-to"`
// ActivityPub URI of this fave
URI string `bun:",notnull"`
} }

View File

@ -0,0 +1,100 @@
/*
GoToSocial
Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gtsmodel_test
import (
"testing"
"time"
"github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
)
func happyStatusFave() *gtsmodel.StatusFave {
return &gtsmodel.StatusFave{
ID: "01FE91RJR88PSEEE30EV35QR8N",
CreatedAt: time.Now(),
AccountID: "01FE96MAE58MXCE5C4SSMEMCEK",
Account: nil,
TargetAccountID: "01FE96MXRHWZHKC0WH5FT82H1A",
TargetAccount: nil,
StatusID: "01FE96NBPNJNY26730FT6GZTFE",
Status: nil,
URI: "https://example.org/users/user1/activity/faves/01FE91RJR88PSEEE30EV35QR8N",
}
}
type StatusFaveValidateTestSuite struct {
suite.Suite
}
func (suite *StatusFaveValidateTestSuite) TestValidateStatusFaveHappyPath() {
// no problem here
f := happyStatusFave()
err := gtsmodel.ValidateStruct(*f)
suite.NoError(err)
}
func (suite *StatusFaveValidateTestSuite) TestValidateStatusFaveBadID() {
f := happyStatusFave()
f.ID = ""
err := gtsmodel.ValidateStruct(*f)
suite.EqualError(err, "Key: 'StatusFave.ID' Error:Field validation for 'ID' failed on the 'required' tag")
f.ID = "01FE96W293ZPRG9FQQP48HK8N001FE96W32AT24VYBGM12WN3GKB"
err = gtsmodel.ValidateStruct(*f)
suite.EqualError(err, "Key: 'StatusFave.ID' Error:Field validation for 'ID' failed on the 'ulid' tag")
}
func (suite *StatusFaveValidateTestSuite) TestValidateStatusFaveDodgyStatusID() {
f := happyStatusFave()
f.StatusID = "9HZJ76B6VXSKF"
err := gtsmodel.ValidateStruct(*f)
suite.EqualError(err, "Key: 'StatusFave.StatusID' Error:Field validation for 'StatusID' failed on the 'ulid' tag")
f.StatusID = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!!!!!!!!!!!!"
err = gtsmodel.ValidateStruct(*f)
suite.EqualError(err, "Key: 'StatusFave.StatusID' Error:Field validation for 'StatusID' failed on the 'ulid' tag")
}
func (suite *StatusFaveValidateTestSuite) TestValidateStatusFaveNoCreatedAt() {
f := happyStatusFave()
f.CreatedAt = time.Time{}
err := gtsmodel.ValidateStruct(*f)
suite.EqualError(err, "Key: 'StatusFave.CreatedAt' Error:Field validation for 'CreatedAt' failed on the 'required' tag")
}
func (suite *StatusFaveValidateTestSuite) TestValidateStatusFaveNoURI() {
f := happyStatusFave()
f.URI = ""
err := gtsmodel.ValidateStruct(*f)
suite.EqualError(err, "Key: 'StatusFave.URI' Error:Field validation for 'URI' failed on the 'required' tag")
f.URI = "this-is-not-a-valid-url"
err = gtsmodel.ValidateStruct(*f)
suite.EqualError(err, "Key: 'StatusFave.URI' Error:Field validation for 'URI' failed on the 'url' tag")
}
func TestStatusFaveValidateTestSuite(t *testing.T) {
suite.Run(t, new(StatusFaveValidateTestSuite))
}

View File

@ -29,7 +29,7 @@ type User struct {
ID string `validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"` // id of this item in the database 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 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 UpdatedAt time.Time `validate:"required" bun:",nullzero,notnull,default:current_timestamp"` // when was item last updated
Email string `validate:"required_with=ConfirmedAt" bun:",nullzero,notnull,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 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. 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. 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. 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.

View File

@ -33,7 +33,7 @@ func happyUser() *gtsmodel.User {
LastEmailedAt: time.Now(), LastEmailedAt: time.Now(),
ConfirmationToken: "", ConfirmationToken: "",
ConfirmedAt: time.Now(), ConfirmedAt: time.Now(),
ConfirmationSentAt: time.Now(), ConfirmationSentAt: time.Time{},
UnconfirmedEmail: "", UnconfirmedEmail: "",
Moderator: false, Moderator: false,
Admin: false, Admin: false,

View File

@ -49,7 +49,7 @@ func (p *processor) processFromClientAPI(ctx context.Context, clientMsg gtsmodel
return err return err
} }
if status.VisibilityAdvanced != nil && status.VisibilityAdvanced.Federated { if status.VisibilityAdvanced.Federated {
return p.federateStatus(ctx, status) return p.federateStatus(ctx, status)
} }
case gtsmodel.ActivityStreamsFollow: case gtsmodel.ActivityStreamsFollow:

View File

@ -44,10 +44,8 @@ func (p *processor) Boost(ctx context.Context, requestingAccount *gtsmodel.Accou
if !visible { if !visible {
return nil, gtserror.NewErrorNotFound(errors.New("status is not visible")) return nil, gtserror.NewErrorNotFound(errors.New("status is not visible"))
} }
if targetStatus.VisibilityAdvanced != nil { if !targetStatus.VisibilityAdvanced.Boostable {
if !targetStatus.VisibilityAdvanced.Boostable { return nil, gtserror.NewErrorForbidden(errors.New("status is not boostable"))
return nil, gtserror.NewErrorForbidden(errors.New("status is not boostable"))
}
} }
// it's visible! it's boostable! so let's boost the FUCK out of it // it's visible! it's boostable! so let's boost the FUCK out of it

View File

@ -47,10 +47,8 @@ func (p *processor) Fave(ctx context.Context, requestingAccount *gtsmodel.Accoun
if !visible { if !visible {
return nil, gtserror.NewErrorNotFound(errors.New("status is not visible")) return nil, gtserror.NewErrorNotFound(errors.New("status is not visible"))
} }
if targetStatus.VisibilityAdvanced != nil { if !targetStatus.VisibilityAdvanced.Likeable {
if !targetStatus.VisibilityAdvanced.Likeable { return nil, gtserror.NewErrorForbidden(errors.New("status is not faveable"))
return nil, gtserror.NewErrorForbidden(errors.New("status is not faveable"))
}
} }
// first check if the status is already faved, if so we don't need to do anything // first check if the status is already faved, if so we don't need to do anything

View File

@ -33,7 +33,7 @@ import (
func (p *processor) ProcessVisibility(ctx context.Context, form *apimodel.AdvancedStatusCreateForm, accountDefaultVis gtsmodel.Visibility, status *gtsmodel.Status) error { func (p *processor) ProcessVisibility(ctx context.Context, form *apimodel.AdvancedStatusCreateForm, accountDefaultVis gtsmodel.Visibility, status *gtsmodel.Status) error {
// by default all flags are set to true // by default all flags are set to true
gtsAdvancedVis := &gtsmodel.VisibilityAdvanced{ gtsAdvancedVis := gtsmodel.VisibilityAdvanced{
Federated: true, Federated: true,
Boostable: true, Boostable: true,
Replyable: true, Replyable: true,
@ -123,11 +123,8 @@ func (p *processor) ProcessReplyToID(ctx context.Context, form *apimodel.Advance
} }
return fmt.Errorf("status with id %s not replyable: %s", form.InReplyToID, err) return fmt.Errorf("status with id %s not replyable: %s", form.InReplyToID, err)
} }
if !repliedStatus.VisibilityAdvanced.Replyable {
if repliedStatus.VisibilityAdvanced != nil { return fmt.Errorf("status with id %s is marked as not replyable", form.InReplyToID)
if !repliedStatus.VisibilityAdvanced.Replyable {
return fmt.Errorf("status with id %s is marked as not replyable", form.InReplyToID)
}
} }
// check replied account is known to us // check replied account is known to us

View File

@ -149,7 +149,7 @@ func NewTestUsers() map[string]*gtsmodel.User {
ChosenLanguages: []string{}, ChosenLanguages: []string{},
FilteredLanguages: []string{}, FilteredLanguages: []string{},
Locale: "en", Locale: "en",
CreatedByApplicationID: "", CreatedByApplicationID: "01F8MGY43H3N2C8EWPR2FPYEXG",
LastEmailedAt: time.Time{}, LastEmailedAt: time.Time{},
ConfirmationToken: "a5a280bd-34be-44a3-8330-a57eaf61b8dd", ConfirmationToken: "a5a280bd-34be-44a3-8330-a57eaf61b8dd",
ConfirmedAt: time.Time{}, ConfirmedAt: time.Time{},
@ -179,7 +179,7 @@ func NewTestUsers() map[string]*gtsmodel.User {
ChosenLanguages: []string{"en"}, ChosenLanguages: []string{"en"},
FilteredLanguages: []string{}, FilteredLanguages: []string{},
Locale: "en", Locale: "en",
CreatedByApplicationID: "", CreatedByApplicationID: "01F8MGXQRHYF5QPMTMXP78QC2F",
LastEmailedAt: time.Now().Add(-30 * time.Minute), LastEmailedAt: time.Now().Add(-30 * time.Minute),
ConfirmationToken: "", ConfirmationToken: "",
ConfirmedAt: time.Now().Add(-72 * time.Hour), ConfirmedAt: time.Now().Add(-72 * time.Hour),
@ -239,7 +239,7 @@ func NewTestUsers() map[string]*gtsmodel.User {
ChosenLanguages: []string{"en"}, ChosenLanguages: []string{"en"},
FilteredLanguages: []string{}, FilteredLanguages: []string{},
Locale: "en", Locale: "en",
CreatedByApplicationID: "", CreatedByApplicationID: "01F8MGY43H3N2C8EWPR2FPYEXG",
LastEmailedAt: time.Now().Add(-55 * time.Minute), LastEmailedAt: time.Now().Add(-55 * time.Minute),
ConfirmationToken: "", ConfirmationToken: "",
ConfirmedAt: time.Now().Add(-34 * time.Hour), ConfirmedAt: time.Now().Add(-34 * time.Hour),
@ -799,6 +799,7 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
CreatedAt: time.Now().Add(-71 * time.Hour), CreatedAt: time.Now().Add(-71 * time.Hour),
UpdatedAt: time.Now().Add(-71 * time.Hour), UpdatedAt: time.Now().Add(-71 * time.Hour),
Local: true, Local: true,
AccountURI: "http://localhost:8080/users/admin",
AccountID: "01F8MH17FWEB39HZJ76B6VXSKF", AccountID: "01F8MH17FWEB39HZJ76B6VXSKF",
InReplyToID: "", InReplyToID: "",
BoostOfID: "", BoostOfID: "",
@ -807,7 +808,7 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
Sensitive: false, Sensitive: false,
Language: "en", Language: "en",
CreatedWithApplicationID: "01F8MGXQRHYF5QPMTMXP78QC2F", CreatedWithApplicationID: "01F8MGXQRHYF5QPMTMXP78QC2F",
VisibilityAdvanced: &gtsmodel.VisibilityAdvanced{ VisibilityAdvanced: gtsmodel.VisibilityAdvanced{
Federated: true, Federated: true,
Boostable: true, Boostable: true,
Replyable: true, Replyable: true,
@ -823,6 +824,7 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
CreatedAt: time.Now().Add(-70 * time.Hour), CreatedAt: time.Now().Add(-70 * time.Hour),
UpdatedAt: time.Now().Add(-70 * time.Hour), UpdatedAt: time.Now().Add(-70 * time.Hour),
Local: true, Local: true,
AccountURI: "http://localhost:8080/users/admin",
AccountID: "01F8MH17FWEB39HZJ76B6VXSKF", AccountID: "01F8MH17FWEB39HZJ76B6VXSKF",
InReplyToID: "", InReplyToID: "",
BoostOfID: "", BoostOfID: "",
@ -831,7 +833,7 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
Sensitive: true, Sensitive: true,
Language: "en", Language: "en",
CreatedWithApplicationID: "01F8MGXQRHYF5QPMTMXP78QC2F", CreatedWithApplicationID: "01F8MGXQRHYF5QPMTMXP78QC2F",
VisibilityAdvanced: &gtsmodel.VisibilityAdvanced{ VisibilityAdvanced: gtsmodel.VisibilityAdvanced{
Federated: true, Federated: true,
Boostable: true, Boostable: true,
Replyable: true, Replyable: true,
@ -847,6 +849,7 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
CreatedAt: time.Now().Add(-47 * time.Hour), CreatedAt: time.Now().Add(-47 * time.Hour),
UpdatedAt: time.Now().Add(-47 * time.Hour), UpdatedAt: time.Now().Add(-47 * time.Hour),
Local: true, Local: true,
AccountURI: "http://localhost:8080/users/the_mighty_zork",
AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF", AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF",
InReplyToID: "", InReplyToID: "",
BoostOfID: "", BoostOfID: "",
@ -855,7 +858,7 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
Sensitive: true, Sensitive: true,
Language: "en", Language: "en",
CreatedWithApplicationID: "01F8MGY43H3N2C8EWPR2FPYEXG", CreatedWithApplicationID: "01F8MGY43H3N2C8EWPR2FPYEXG",
VisibilityAdvanced: &gtsmodel.VisibilityAdvanced{ VisibilityAdvanced: gtsmodel.VisibilityAdvanced{
Federated: true, Federated: true,
Boostable: true, Boostable: true,
Replyable: true, Replyable: true,
@ -871,6 +874,7 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
CreatedAt: time.Now().Add(-46 * time.Hour), CreatedAt: time.Now().Add(-46 * time.Hour),
UpdatedAt: time.Now().Add(-46 * time.Hour), UpdatedAt: time.Now().Add(-46 * time.Hour),
Local: true, Local: true,
AccountURI: "http://localhost:8080/users/the_mighty_zork",
AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF", AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF",
InReplyToID: "", InReplyToID: "",
BoostOfID: "", BoostOfID: "",
@ -879,7 +883,7 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
Sensitive: false, Sensitive: false,
Language: "en", Language: "en",
CreatedWithApplicationID: "01F8MGY43H3N2C8EWPR2FPYEXG", CreatedWithApplicationID: "01F8MGY43H3N2C8EWPR2FPYEXG",
VisibilityAdvanced: &gtsmodel.VisibilityAdvanced{ VisibilityAdvanced: gtsmodel.VisibilityAdvanced{
Federated: false, Federated: false,
Boostable: true, Boostable: true,
Replyable: true, Replyable: true,
@ -895,6 +899,7 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
CreatedAt: time.Now().Add(-45 * time.Hour), CreatedAt: time.Now().Add(-45 * time.Hour),
UpdatedAt: time.Now().Add(-45 * time.Hour), UpdatedAt: time.Now().Add(-45 * time.Hour),
Local: true, Local: true,
AccountURI: "http://localhost:8080/users/the_mighty_zork",
AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF", AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF",
InReplyToID: "", InReplyToID: "",
BoostOfID: "", BoostOfID: "",
@ -903,7 +908,7 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
Sensitive: false, Sensitive: false,
Language: "en", Language: "en",
CreatedWithApplicationID: "01F8MGY43H3N2C8EWPR2FPYEXG", CreatedWithApplicationID: "01F8MGY43H3N2C8EWPR2FPYEXG",
VisibilityAdvanced: &gtsmodel.VisibilityAdvanced{ VisibilityAdvanced: gtsmodel.VisibilityAdvanced{
Federated: true, Federated: true,
Boostable: false, Boostable: false,
Replyable: false, Replyable: false,
@ -920,6 +925,7 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
CreatedAt: time.Now().Add(-1 * time.Hour), CreatedAt: time.Now().Add(-1 * time.Hour),
UpdatedAt: time.Now().Add(-1 * time.Hour), UpdatedAt: time.Now().Add(-1 * time.Hour),
Local: true, Local: true,
AccountURI: "http://localhost:8080/users/the_mighty_zork",
AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF", AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF",
InReplyToID: "", InReplyToID: "",
BoostOfID: "", BoostOfID: "",
@ -928,7 +934,7 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
Sensitive: false, Sensitive: false,
Language: "en", Language: "en",
CreatedWithApplicationID: "01F8MGY43H3N2C8EWPR2FPYEXG", CreatedWithApplicationID: "01F8MGY43H3N2C8EWPR2FPYEXG",
VisibilityAdvanced: &gtsmodel.VisibilityAdvanced{ VisibilityAdvanced: gtsmodel.VisibilityAdvanced{
Federated: true, Federated: true,
Boostable: true, Boostable: true,
Replyable: true, Replyable: true,
@ -945,6 +951,7 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
CreatedAt: time.Now().Add(-1 * time.Minute), CreatedAt: time.Now().Add(-1 * time.Minute),
UpdatedAt: time.Now().Add(-1 * time.Minute), UpdatedAt: time.Now().Add(-1 * time.Minute),
Local: true, Local: true,
AccountURI: "http://localhost:8080/users/the_mighty_zork",
AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF", AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF",
InReplyToID: "", InReplyToID: "",
BoostOfID: "", BoostOfID: "",
@ -953,7 +960,7 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
Sensitive: false, Sensitive: false,
Language: "en", Language: "en",
CreatedWithApplicationID: "01F8MGY43H3N2C8EWPR2FPYEXG", CreatedWithApplicationID: "01F8MGY43H3N2C8EWPR2FPYEXG",
VisibilityAdvanced: &gtsmodel.VisibilityAdvanced{ VisibilityAdvanced: gtsmodel.VisibilityAdvanced{
Federated: true, Federated: true,
Boostable: true, Boostable: true,
Replyable: true, Replyable: true,
@ -969,6 +976,7 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
CreatedAt: time.Now().Add(-189 * time.Hour), CreatedAt: time.Now().Add(-189 * time.Hour),
UpdatedAt: time.Now().Add(-189 * time.Hour), UpdatedAt: time.Now().Add(-189 * time.Hour),
Local: true, Local: true,
AccountURI: "http://localhost:8080/users/1happyturtle",
AccountID: "01F8MH5NBDF2MV7CTC4Q5128HF", AccountID: "01F8MH5NBDF2MV7CTC4Q5128HF",
InReplyToID: "", InReplyToID: "",
BoostOfID: "", BoostOfID: "",
@ -977,7 +985,7 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
Sensitive: true, Sensitive: true,
Language: "en", Language: "en",
CreatedWithApplicationID: "01F8MGYG9E893WRHW0TAEXR8GJ", CreatedWithApplicationID: "01F8MGYG9E893WRHW0TAEXR8GJ",
VisibilityAdvanced: &gtsmodel.VisibilityAdvanced{ VisibilityAdvanced: gtsmodel.VisibilityAdvanced{
Federated: true, Federated: true,
Boostable: true, Boostable: true,
Replyable: true, Replyable: true,
@ -993,6 +1001,7 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
CreatedAt: time.Now().Add(-1 * time.Minute), CreatedAt: time.Now().Add(-1 * time.Minute),
UpdatedAt: time.Now().Add(-1 * time.Minute), UpdatedAt: time.Now().Add(-1 * time.Minute),
Local: true, Local: true,
AccountURI: "http://localhost:8080/users/1happyturtle",
AccountID: "01F8MH5NBDF2MV7CTC4Q5128HF", AccountID: "01F8MH5NBDF2MV7CTC4Q5128HF",
InReplyToID: "", InReplyToID: "",
BoostOfID: "", BoostOfID: "",
@ -1001,7 +1010,7 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
Sensitive: true, Sensitive: true,
Language: "en", Language: "en",
CreatedWithApplicationID: "01F8MGYG9E893WRHW0TAEXR8GJ", CreatedWithApplicationID: "01F8MGYG9E893WRHW0TAEXR8GJ",
VisibilityAdvanced: &gtsmodel.VisibilityAdvanced{ VisibilityAdvanced: gtsmodel.VisibilityAdvanced{
Federated: true, Federated: true,
Boostable: true, Boostable: true,
Replyable: false, Replyable: false,
@ -1017,6 +1026,7 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
CreatedAt: time.Now().Add(-2 * time.Minute), CreatedAt: time.Now().Add(-2 * time.Minute),
UpdatedAt: time.Now().Add(-2 * time.Minute), UpdatedAt: time.Now().Add(-2 * time.Minute),
Local: true, Local: true,
AccountURI: "http://localhost:8080/users/1happyturtle",
AccountID: "01F8MH5NBDF2MV7CTC4Q5128HF", AccountID: "01F8MH5NBDF2MV7CTC4Q5128HF",
InReplyToID: "", InReplyToID: "",
BoostOfID: "", BoostOfID: "",
@ -1025,7 +1035,7 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
Sensitive: true, Sensitive: true,
Language: "en", Language: "en",
CreatedWithApplicationID: "01F8MGYG9E893WRHW0TAEXR8GJ", CreatedWithApplicationID: "01F8MGYG9E893WRHW0TAEXR8GJ",
VisibilityAdvanced: &gtsmodel.VisibilityAdvanced{ VisibilityAdvanced: gtsmodel.VisibilityAdvanced{
Federated: true, Federated: true,
Boostable: true, Boostable: true,
Replyable: false, Replyable: false,
@ -1041,6 +1051,7 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
CreatedAt: time.Now().Add(-1 * time.Minute), CreatedAt: time.Now().Add(-1 * time.Minute),
UpdatedAt: time.Now().Add(-1 * time.Minute), UpdatedAt: time.Now().Add(-1 * time.Minute),
Local: true, Local: true,
AccountURI: "http://localhost:8080/users/1happyturtle",
AccountID: "01F8MH5NBDF2MV7CTC4Q5128HF", AccountID: "01F8MH5NBDF2MV7CTC4Q5128HF",
InReplyToID: "", InReplyToID: "",
BoostOfID: "", BoostOfID: "",
@ -1049,7 +1060,7 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
Sensitive: true, Sensitive: true,
Language: "en", Language: "en",
CreatedWithApplicationID: "01F8MGYG9E893WRHW0TAEXR8GJ", CreatedWithApplicationID: "01F8MGYG9E893WRHW0TAEXR8GJ",
VisibilityAdvanced: &gtsmodel.VisibilityAdvanced{ VisibilityAdvanced: gtsmodel.VisibilityAdvanced{
Federated: false, Federated: false,
Boostable: false, Boostable: false,
Replyable: true, Replyable: true,
@ -1065,6 +1076,7 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
CreatedAt: time.Now().Add(-1 * time.Minute), CreatedAt: time.Now().Add(-1 * time.Minute),
UpdatedAt: time.Now().Add(-1 * time.Minute), UpdatedAt: time.Now().Add(-1 * time.Minute),
Local: true, Local: true,
AccountURI: "http://localhost:8080/users/1happyturtle",
MentionIDs: []string{"01FDF2HM2NF6FSRZCDEDV451CN"}, MentionIDs: []string{"01FDF2HM2NF6FSRZCDEDV451CN"},
AccountID: "01F8MH5NBDF2MV7CTC4Q5128HF", AccountID: "01F8MH5NBDF2MV7CTC4Q5128HF",
InReplyToID: "01F8MHAMCHF6Y650WCRSCP4WMY", InReplyToID: "01F8MHAMCHF6Y650WCRSCP4WMY",
@ -1076,7 +1088,7 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
Sensitive: false, Sensitive: false,
Language: "en", Language: "en",
CreatedWithApplicationID: "01F8MGYG9E893WRHW0TAEXR8GJ", CreatedWithApplicationID: "01F8MGYG9E893WRHW0TAEXR8GJ",
VisibilityAdvanced: &gtsmodel.VisibilityAdvanced{ VisibilityAdvanced: gtsmodel.VisibilityAdvanced{
Federated: true, Federated: true,
Boostable: true, Boostable: true,
Replyable: true, Replyable: true,