mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-25 23:23:32 -06:00
[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
This commit is contained in:
parent
52fe681ba2
commit
ac6ed3d939
376 changed files with 337942 additions and 298092 deletions
12
internal/cache/account.go
vendored
12
internal/cache/account.go
vendored
|
|
@ -103,16 +103,16 @@ func copyAccount(account *gtsmodel.Account) *gtsmodel.Account {
|
|||
Fields: account.Fields,
|
||||
Note: account.Note,
|
||||
NoteRaw: account.NoteRaw,
|
||||
Memorial: account.Memorial,
|
||||
Memorial: copyBoolPtr(account.Memorial),
|
||||
MovedToAccountID: account.MovedToAccountID,
|
||||
Bot: copyBoolPtr(account.Bot),
|
||||
CreatedAt: account.CreatedAt,
|
||||
UpdatedAt: account.UpdatedAt,
|
||||
Bot: account.Bot,
|
||||
Reason: account.Reason,
|
||||
Locked: account.Locked,
|
||||
Discoverable: account.Discoverable,
|
||||
Locked: copyBoolPtr(account.Locked),
|
||||
Discoverable: copyBoolPtr(account.Discoverable),
|
||||
Privacy: account.Privacy,
|
||||
Sensitive: account.Sensitive,
|
||||
Sensitive: copyBoolPtr(account.Sensitive),
|
||||
Language: account.Language,
|
||||
StatusFormat: account.StatusFormat,
|
||||
URI: account.URI,
|
||||
|
|
@ -131,7 +131,7 @@ func copyAccount(account *gtsmodel.Account) *gtsmodel.Account {
|
|||
SensitizedAt: account.SensitizedAt,
|
||||
SilencedAt: account.SilencedAt,
|
||||
SuspendedAt: account.SuspendedAt,
|
||||
HideCollections: account.HideCollections,
|
||||
HideCollections: copyBoolPtr(account.HideCollections),
|
||||
SuspensionOrigin: account.SuspensionOrigin,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
14
internal/cache/status.go
vendored
14
internal/cache/status.go
vendored
|
|
@ -102,9 +102,9 @@ func copyStatus(status *gtsmodel.Status) *gtsmodel.Status {
|
|||
Mentions: nil,
|
||||
EmojiIDs: status.EmojiIDs,
|
||||
Emojis: nil,
|
||||
Local: copyBoolPtr(status.Local),
|
||||
CreatedAt: status.CreatedAt,
|
||||
UpdatedAt: status.UpdatedAt,
|
||||
Local: status.Local,
|
||||
AccountID: status.AccountID,
|
||||
Account: nil,
|
||||
AccountURI: status.AccountURI,
|
||||
|
|
@ -119,15 +119,15 @@ func copyStatus(status *gtsmodel.Status) *gtsmodel.Status {
|
|||
BoostOfAccount: nil,
|
||||
ContentWarning: status.ContentWarning,
|
||||
Visibility: status.Visibility,
|
||||
Sensitive: status.Sensitive,
|
||||
Sensitive: copyBoolPtr(status.Sensitive),
|
||||
Language: status.Language,
|
||||
CreatedWithApplicationID: status.CreatedWithApplicationID,
|
||||
Federated: status.Federated,
|
||||
Boostable: status.Boostable,
|
||||
Replyable: status.Replyable,
|
||||
Likeable: status.Likeable,
|
||||
ActivityStreamsType: status.ActivityStreamsType,
|
||||
Text: status.Text,
|
||||
Pinned: status.Pinned,
|
||||
Pinned: copyBoolPtr(status.Pinned),
|
||||
Federated: copyBoolPtr(status.Federated),
|
||||
Boostable: copyBoolPtr(status.Boostable),
|
||||
Replyable: copyBoolPtr(status.Replyable),
|
||||
Likeable: copyBoolPtr(status.Likeable),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
26
internal/cache/status_test.go
vendored
26
internal/cache/status_test.go
vendored
|
|
@ -72,6 +72,32 @@ func (suite *StatusCacheTestSuite) TestStatusCache() {
|
|||
}
|
||||
}
|
||||
|
||||
func (suite *StatusCacheTestSuite) TestBoolPointerCopying() {
|
||||
originalStatus := suite.data["local_account_1_status_1"]
|
||||
|
||||
// mark the status as pinned + cache it
|
||||
pinned := true
|
||||
originalStatus.Pinned = &pinned
|
||||
suite.cache.Put(originalStatus)
|
||||
|
||||
// retrieve it
|
||||
cachedStatus, ok := suite.cache.GetByID(originalStatus.ID)
|
||||
if !ok {
|
||||
suite.FailNow("status wasn't retrievable from cache")
|
||||
}
|
||||
|
||||
// we should be able to change the original status values + cached
|
||||
// values independently since they use different pointers
|
||||
suite.True(*cachedStatus.Pinned)
|
||||
*originalStatus.Pinned = false
|
||||
suite.False(*originalStatus.Pinned)
|
||||
suite.True(*cachedStatus.Pinned)
|
||||
*originalStatus.Pinned = true
|
||||
*cachedStatus.Pinned = false
|
||||
suite.True(*originalStatus.Pinned)
|
||||
suite.False(*cachedStatus.Pinned)
|
||||
}
|
||||
|
||||
func TestStatusCache(t *testing.T) {
|
||||
suite.Run(t, &StatusCacheTestSuite{})
|
||||
}
|
||||
|
|
|
|||
31
internal/cache/util.go
vendored
Normal file
31
internal/cache/util.go
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
GoToSocial
|
||||
Copyright (C) 2021-2022 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 cache
|
||||
|
||||
// copyBoolPtr returns a bool pointer with the same value as the pointer passed into it.
|
||||
//
|
||||
// Useful when copying things from the cache to a caller.
|
||||
func copyBoolPtr(in *bool) *bool {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
b := new(bool)
|
||||
*b = *in
|
||||
return b
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue