mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 08:02:26 -05:00
[chore] Migrate accounts to new table, relax uniqueness constraint of actor url and collections (#3928)
* [chore] Migrate accounts to new table, relax uniqueness constraint of actor url and collections * fiddle with it! (that's what she said) * remove unused cache fields * sillyness * fix tiny whoopsie
This commit is contained in:
parent
650be1e8d0
commit
8ae2440da3
43 changed files with 1298 additions and 566 deletions
|
|
@ -70,19 +70,10 @@ func (c *Converter) ASRepresentationToAccount(
|
|||
acct.URI = uri
|
||||
|
||||
// Check whether account is a usable actor type.
|
||||
switch acct.ActorType = accountable.GetTypeName(); acct.ActorType {
|
||||
|
||||
// people, groups, and organizations aren't bots
|
||||
case ap.ActorPerson, ap.ActorGroup, ap.ActorOrganization:
|
||||
acct.Bot = util.Ptr(false)
|
||||
|
||||
// apps and services are
|
||||
case ap.ActorApplication, ap.ActorService:
|
||||
acct.Bot = util.Ptr(true)
|
||||
|
||||
// we don't know what this is!
|
||||
default:
|
||||
err := gtserror.Newf("unusable actor type for %s", uri)
|
||||
actorTypeName := accountable.GetTypeName()
|
||||
acct.ActorType = gtsmodel.ParseAccountActorType(actorTypeName)
|
||||
if acct.ActorType == gtsmodel.AccountActorTypeUnknown {
|
||||
err := gtserror.Newf("unusable actor type %s for %s", actorTypeName, uri)
|
||||
return nil, gtserror.SetMalformed(err)
|
||||
}
|
||||
|
||||
|
|
@ -161,7 +152,7 @@ func (c *Converter) ASRepresentationToAccount(
|
|||
acct.Note = ap.ExtractSummary(accountable)
|
||||
|
||||
// Assume not memorial (todo)
|
||||
acct.Memorial = util.Ptr(false)
|
||||
acct.MemorializedAt = time.Time{}
|
||||
|
||||
// Extract 'manuallyApprovesFollowers' aka locked account (default = true).
|
||||
manuallyApprovesFollowers := ap.GetManuallyApprovesFollowers(accountable)
|
||||
|
|
|
|||
|
|
@ -204,7 +204,6 @@ func (suite *ASToInternalTestSuite) TestParseOwncastService() {
|
|||
suite.Equal("https://owncast.example.org/logo/external", acct.HeaderRemoteURL)
|
||||
suite.Equal("Rob's Owncast Server", acct.DisplayName)
|
||||
suite.Equal("linux audio stuff", acct.Note)
|
||||
suite.True(*acct.Bot)
|
||||
suite.False(*acct.Locked)
|
||||
suite.True(*acct.Discoverable)
|
||||
suite.Equal("https://owncast.example.org/federation/user/rgh", acct.URI)
|
||||
|
|
@ -212,7 +211,7 @@ func (suite *ASToInternalTestSuite) TestParseOwncastService() {
|
|||
suite.Equal("https://owncast.example.org/federation/user/rgh/inbox", acct.InboxURI)
|
||||
suite.Equal("https://owncast.example.org/federation/user/rgh/outbox", acct.OutboxURI)
|
||||
suite.Equal("https://owncast.example.org/federation/user/rgh/followers", acct.FollowersURI)
|
||||
suite.Equal("Service", acct.ActorType)
|
||||
suite.Equal(gtsmodel.AccountActorTypeService, acct.ActorType)
|
||||
suite.Equal("https://owncast.example.org/federation/user/rgh#main-key", acct.PublicKeyURI)
|
||||
|
||||
acct.ID = "01G42D57DTCJQE8XT9KD4K88RK"
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ import (
|
|||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/log"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/uris"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/util"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/util/xslices"
|
||||
)
|
||||
|
||||
|
|
@ -49,7 +48,7 @@ func (c *Converter) AccountToAS(
|
|||
// accountable is a service if this
|
||||
// is a bot account, otherwise a person.
|
||||
var accountable ap.Accountable
|
||||
if util.PtrOrZero(a.Bot) {
|
||||
if a.ActorType.IsBot() {
|
||||
accountable = streams.NewActivityStreamsService()
|
||||
} else {
|
||||
accountable = streams.NewActivityStreamsPerson()
|
||||
|
|
@ -393,7 +392,7 @@ func (c *Converter) AccountToASMinimal(
|
|||
// accountable is a service if this
|
||||
// is a bot account, otherwise a person.
|
||||
var accountable ap.Accountable
|
||||
if util.PtrOrZero(a.Bot) {
|
||||
if a.ActorType.IsBot() {
|
||||
accountable = streams.NewActivityStreamsService()
|
||||
} else {
|
||||
accountable = streams.NewActivityStreamsPerson()
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import (
|
|||
"github.com/superseriousbusiness/gotosocial/internal/ap"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/util"
|
||||
"github.com/superseriousbusiness/gotosocial/testrig"
|
||||
)
|
||||
|
||||
|
|
@ -100,7 +99,7 @@ func (suite *InternalToASTestSuite) TestAccountToASBot() {
|
|||
*testAccount = *suite.testAccounts["local_account_1"] // take zork for this test
|
||||
|
||||
// Update zork to be a bot.
|
||||
testAccount.Bot = util.Ptr(true)
|
||||
testAccount.ActorType = gtsmodel.AccountActorTypeService
|
||||
if err := suite.state.DB.UpdateAccount(context.Background(), testAccount); err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -361,7 +361,6 @@ func (c *Converter) accountToAPIAccountPublic(ctx context.Context, a *gtsmodel.A
|
|||
var (
|
||||
locked = util.PtrOrValue(a.Locked, true)
|
||||
discoverable = util.PtrOrValue(a.Discoverable, false)
|
||||
bot = util.PtrOrValue(a.Bot, false)
|
||||
)
|
||||
|
||||
// Remaining properties are simple and
|
||||
|
|
@ -374,7 +373,7 @@ func (c *Converter) accountToAPIAccountPublic(ctx context.Context, a *gtsmodel.A
|
|||
DisplayName: a.DisplayName,
|
||||
Locked: locked,
|
||||
Discoverable: discoverable,
|
||||
Bot: bot,
|
||||
Bot: a.ActorType.IsBot(),
|
||||
CreatedAt: util.FormatISO8601(a.CreatedAt),
|
||||
Note: a.Note,
|
||||
URL: a.URL,
|
||||
|
|
@ -518,7 +517,7 @@ func (c *Converter) AccountToAPIAccountBlocked(ctx context.Context, a *gtsmodel.
|
|||
ID: a.ID,
|
||||
Username: a.Username,
|
||||
Acct: acct,
|
||||
Bot: *a.Bot,
|
||||
Bot: a.ActorType.IsBot(),
|
||||
CreatedAt: util.FormatISO8601(a.CreatedAt),
|
||||
URL: a.URL,
|
||||
// Empty array (not nillable).
|
||||
|
|
|
|||
|
|
@ -404,7 +404,7 @@ func (suite *InternalToFrontendTestSuite) TestLocalInstanceAccountToFrontendPubl
|
|||
"display_name": "",
|
||||
"locked": false,
|
||||
"discoverable": true,
|
||||
"bot": false,
|
||||
"bot": true,
|
||||
"created_at": "2020-05-17T13:10:59.000Z",
|
||||
"note": "",
|
||||
"url": "http://localhost:8080/@localhost:8080",
|
||||
|
|
@ -444,7 +444,7 @@ func (suite *InternalToFrontendTestSuite) TestLocalInstanceAccountToFrontendBloc
|
|||
"display_name": "",
|
||||
"locked": false,
|
||||
"discoverable": false,
|
||||
"bot": false,
|
||||
"bot": true,
|
||||
"created_at": "2020-05-17T13:10:59.000Z",
|
||||
"note": "",
|
||||
"url": "http://localhost:8080/@localhost:8080",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue