[bugfix] Fix migration unsetting bot flag (#4098)

Fixes an issue in the migration where bot actor type was being incorrectly set to Person.

Closes https://codeberg.org/superseriousbusiness/gotosocial/issues/4086

Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4098
Co-authored-by: tobi <tobi.smethurst@protonmail.com>
Co-committed-by: tobi <tobi.smethurst@protonmail.com>
This commit is contained in:
tobi
2025-04-30 11:17:20 +00:00
committed by tobi
parent ef0f8a55c6
commit ac01652de9

View File

@@ -28,6 +28,7 @@ import (
new_gtsmodel "code.superseriousbusiness.org/gotosocial/internal/db/bundb/migrations/20250321131230_relax_account_uri_uniqueness/new" new_gtsmodel "code.superseriousbusiness.org/gotosocial/internal/db/bundb/migrations/20250321131230_relax_account_uri_uniqueness/new"
old_gtsmodel "code.superseriousbusiness.org/gotosocial/internal/db/bundb/migrations/20250321131230_relax_account_uri_uniqueness/old" old_gtsmodel "code.superseriousbusiness.org/gotosocial/internal/db/bundb/migrations/20250321131230_relax_account_uri_uniqueness/old"
"code.superseriousbusiness.org/gotosocial/internal/log" "code.superseriousbusiness.org/gotosocial/internal/log"
"code.superseriousbusiness.org/gotosocial/internal/util"
"github.com/uptrace/bun" "github.com/uptrace/bun"
"github.com/uptrace/bun/dialect" "github.com/uptrace/bun/dialect"
@@ -188,13 +189,27 @@ func init() {
for _, oldAccount := range oldAccounts { for _, oldAccount := range oldAccounts {
var actorType new_gtsmodel.AccountActorType var actorType new_gtsmodel.AccountActorType
if oldAccount.Domain == "" && oldAccount.Username == host { switch {
case oldAccount.Domain != "":
// Not our account, just parse new actor type.
actorType = new_gtsmodel.ParseAccountActorType(oldAccount.ActorType)
case oldAccount.Username == host:
// This is our instance account, override actor // This is our instance account, override actor
// type to Service, as previously it was just person. // type to Service, as previously it was just person.
actorType = new_gtsmodel.AccountActorTypeService actorType = new_gtsmodel.AccountActorTypeService
default:
// Not our instance account. Use old
// *Bot flag to determine actor type.
if util.PtrOrZero(oldAccount.Bot) {
// It's a bot.
actorType = new_gtsmodel.AccountActorTypeApplication
} else { } else {
// Not our instance account, just parse new actor type. // Just normal men, just innocent men.
actorType = new_gtsmodel.ParseAccountActorType(oldAccount.ActorType) actorType = new_gtsmodel.AccountActorTypePerson
}
} }
if actorType == new_gtsmodel.AccountActorTypeUnknown { if actorType == new_gtsmodel.AccountActorTypeUnknown {