mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-13 18:27:30 -06:00
[chore] Move local account settings to separate db table (#2770)
* [chore] Move local account settings to separate database model * don't use separate settings_id
This commit is contained in:
parent
0767647056
commit
7f4a0a1aeb
36 changed files with 525 additions and 191 deletions
|
|
@ -395,12 +395,8 @@ func (suite *InboxPostTestSuite) TestPostUpdate() {
|
|||
suite.EqualValues(requestingAccount.AlsoKnownAsURIs, dbUpdatedAccount.AlsoKnownAsURIs)
|
||||
suite.EqualValues(requestingAccount.MovedToURI, dbUpdatedAccount.MovedToURI)
|
||||
suite.EqualValues(requestingAccount.Bot, dbUpdatedAccount.Bot)
|
||||
suite.EqualValues(requestingAccount.Reason, dbUpdatedAccount.Reason)
|
||||
suite.EqualValues(requestingAccount.Locked, dbUpdatedAccount.Locked)
|
||||
suite.EqualValues(requestingAccount.Discoverable, dbUpdatedAccount.Discoverable)
|
||||
suite.EqualValues(requestingAccount.Privacy, dbUpdatedAccount.Privacy)
|
||||
suite.EqualValues(requestingAccount.Sensitive, dbUpdatedAccount.Sensitive)
|
||||
suite.EqualValues(requestingAccount.Language, dbUpdatedAccount.Language)
|
||||
suite.EqualValues(requestingAccount.URI, dbUpdatedAccount.URI)
|
||||
suite.EqualValues(requestingAccount.URL, dbUpdatedAccount.URL)
|
||||
suite.EqualValues(requestingAccount.InboxURI, dbUpdatedAccount.InboxURI)
|
||||
|
|
@ -414,7 +410,6 @@ func (suite *InboxPostTestSuite) TestPostUpdate() {
|
|||
suite.EqualValues(requestingAccount.SensitizedAt, dbUpdatedAccount.SensitizedAt)
|
||||
suite.EqualValues(requestingAccount.SilencedAt, dbUpdatedAccount.SilencedAt)
|
||||
suite.EqualValues(requestingAccount.SuspendedAt, dbUpdatedAccount.SuspendedAt)
|
||||
suite.EqualValues(requestingAccount.HideCollections, dbUpdatedAccount.HideCollections)
|
||||
suite.EqualValues(requestingAccount.SuspensionOrigin, dbUpdatedAccount.SuspensionOrigin)
|
||||
}
|
||||
|
||||
|
|
@ -464,9 +459,7 @@ func (suite *InboxPostTestSuite) TestPostDelete() {
|
|||
suite.Empty(dbAccount.AvatarRemoteURL)
|
||||
suite.Empty(dbAccount.HeaderMediaAttachmentID)
|
||||
suite.Empty(dbAccount.HeaderRemoteURL)
|
||||
suite.Empty(dbAccount.Reason)
|
||||
suite.Empty(dbAccount.Fields)
|
||||
suite.True(*dbAccount.HideCollections)
|
||||
suite.False(*dbAccount.Discoverable)
|
||||
suite.WithinDuration(time.Now(), dbAccount.SuspendedAt, 30*time.Second)
|
||||
suite.Equal(dbAccount.ID, dbAccount.SuspensionOrigin)
|
||||
|
|
|
|||
|
|
@ -481,7 +481,7 @@ func (suite *AccountUpdateTestSuite) TestUpdateAccountSourceBadContentTypeFormDa
|
|||
if err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
suite.Equal(data["source[status_content_type]"][0], dbAccount.StatusContentType)
|
||||
suite.Equal(data["source[status_content_type]"][0], dbAccount.Settings.StatusContentType)
|
||||
}
|
||||
|
||||
func (suite *AccountUpdateTestSuite) TestAccountUpdateCredentialsPATCHHandlerUpdateStatusContentTypeBad() {
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ func (suite *AccountVerifyTestSuite) TestAccountVerifyGet() {
|
|||
suite.Equal(2, apimodelAccount.FollowingCount)
|
||||
suite.Equal(7, apimodelAccount.StatusesCount)
|
||||
suite.EqualValues(gtsmodel.VisibilityPublic, apimodelAccount.Source.Privacy)
|
||||
suite.Equal(testAccount.Language, apimodelAccount.Source.Language)
|
||||
suite.Equal(testAccount.Settings.Language, apimodelAccount.Source.Language)
|
||||
suite.Equal(testAccount.NoteRaw, apimodelAccount.Source.Note)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,16 +103,22 @@ func (suite *StatusCreateTestSuite) TestPostNewStatus() {
|
|||
}
|
||||
|
||||
func (suite *StatusCreateTestSuite) TestPostNewStatusMarkdown() {
|
||||
// set default post language of account 1 to markdown
|
||||
testAccount := suite.testAccounts["local_account_1"]
|
||||
testAccount.StatusContentType = "text/markdown"
|
||||
a := testAccount
|
||||
// Copy zork.
|
||||
testAccount := >smodel.Account{}
|
||||
*testAccount = *suite.testAccounts["local_account_1"]
|
||||
|
||||
err := suite.db.UpdateAccount(context.Background(), a)
|
||||
// Copy zork's settings.
|
||||
settings := >smodel.AccountSettings{}
|
||||
*settings = *suite.testAccounts["local_account_1"].Settings
|
||||
testAccount.Settings = settings
|
||||
|
||||
// set default post language of zork to markdown
|
||||
testAccount.Settings.StatusContentType = "text/markdown"
|
||||
err := suite.db.UpdateAccountSettings(context.Background(), testAccount.Settings)
|
||||
if err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
suite.Equal(a.StatusContentType, "text/markdown")
|
||||
suite.Equal(testAccount.Settings.StatusContentType, "text/markdown")
|
||||
|
||||
t := suite.testTokens["local_account_1"]
|
||||
oauthToken := oauth.DBTokenToToken(t)
|
||||
|
|
@ -122,7 +128,7 @@ func (suite *StatusCreateTestSuite) TestPostNewStatusMarkdown() {
|
|||
ctx.Set(oauth.SessionAuthorizedApplication, suite.testApplications["application_1"])
|
||||
ctx.Set(oauth.SessionAuthorizedToken, oauthToken)
|
||||
ctx.Set(oauth.SessionAuthorizedUser, suite.testUsers["local_account_1"])
|
||||
ctx.Set(oauth.SessionAuthorizedAccount, a)
|
||||
ctx.Set(oauth.SessionAuthorizedAccount, testAccount)
|
||||
|
||||
ctx.Request = httptest.NewRequest(http.MethodPost, fmt.Sprintf("http://localhost:8080/%s", statuses.BasePath), nil)
|
||||
ctx.Request.Header.Set("accept", "application/json")
|
||||
|
|
|
|||
|
|
@ -100,7 +100,6 @@ func (suite *WebfingerGetTestSuite) funkifyAccountDomain(host string, accountDom
|
|||
targetAccount := >smodel.Account{
|
||||
ID: "01FG1K8EA7SYHEC7V6XKVNC4ZA",
|
||||
Username: "new_account_domain_user",
|
||||
Privacy: gtsmodel.VisibilityDefault,
|
||||
URI: "http://" + host + "/users/new_account_domain_user",
|
||||
URL: "http://" + host + "/@new_account_domain_user",
|
||||
InboxURI: "http://" + host + "/users/new_account_domain_user/inbox",
|
||||
|
|
@ -118,6 +117,10 @@ func (suite *WebfingerGetTestSuite) funkifyAccountDomain(host string, accountDom
|
|||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
if err := suite.db.PutAccountSettings(context.Background(), >smodel.AccountSettings{AccountID: targetAccount.ID}); err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
return targetAccount
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue