summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/db/bundb/account.go5
-rw-r--r--internal/db/bundb/account_test.go11
2 files changed, 14 insertions, 2 deletions
diff --git a/internal/db/bundb/account.go b/internal/db/bundb/account.go
index f7b0a0d4f..5b1dab143 100644
--- a/internal/db/bundb/account.go
+++ b/internal/db/bundb/account.go
@@ -316,12 +316,13 @@ func (a *accountDB) PopulateAccount(ctx context.Context, account *gtsmodel.Accou
}
if account.MovedTo == nil && account.MovedToURI != "" {
- // Account movedTo is not set, fetch from database.
+ // Account movedTo is not set, try to fetch from database,
+ // but only error on real errors since this field is optional.
account.MovedTo, err = a.state.DB.GetAccountByURI(
gtscontext.SetBarebones(ctx),
account.MovedToURI,
)
- if err != nil {
+ if err != nil && !errors.Is(err, db.ErrNoEntries) {
errs.Appendf("error populating moved to account: %w", err)
}
}
diff --git a/internal/db/bundb/account_test.go b/internal/db/bundb/account_test.go
index f01964da8..268c25c59 100644
--- a/internal/db/bundb/account_test.go
+++ b/internal/db/bundb/account_test.go
@@ -482,6 +482,17 @@ func (suite *AccountTestSuite) TestCountAccountPinnedNothingPinned() {
suite.Equal(pinned, 0) // This account has nothing pinned.
}
+func (suite *AccountTestSuite) TestPopulateAccountWithUnknownMovedToURI() {
+ testAccount := &gtsmodel.Account{}
+ *testAccount = *suite.testAccounts["local_account_1"]
+
+ // Set test account MovedToURI to something we don't have in the database.
+ // We should not get an error when populating.
+ testAccount.MovedToURI = "https://unknown-instance.example.org/users/someone_we_dont_know"
+ err := suite.db.PopulateAccount(context.Background(), testAccount)
+ suite.NoError(err)
+}
+
func TestAccountTestSuite(t *testing.T) {
suite.Run(t, new(AccountTestSuite))
}