mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-30 15:42:46 +00:00
[bugfix] Don't error when populating MovedTo if account not found (#2741)
* [bugfix] Don't error when populating MovedTo if account not found * test the thing
This commit is contained in:
parent
03263184d8
commit
0bd95d7b71
|
@ -305,12 +305,13 @@ func (a *accountDB) PopulateAccount(ctx context.Context, account *gtsmodel.Accou
|
||||||
}
|
}
|
||||||
|
|
||||||
if account.MovedTo == nil && account.MovedToURI != "" {
|
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(
|
account.MovedTo, err = a.state.DB.GetAccountByURI(
|
||||||
gtscontext.SetBarebones(ctx),
|
gtscontext.SetBarebones(ctx),
|
||||||
account.MovedToURI,
|
account.MovedToURI,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil && !errors.Is(err, db.ErrNoEntries) {
|
||||||
errs.Appendf("error populating moved to account: %w", err)
|
errs.Appendf("error populating moved to account: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -482,6 +482,17 @@ func (suite *AccountTestSuite) TestCountAccountPinnedNothingPinned() {
|
||||||
suite.Equal(pinned, 0) // This account has nothing pinned.
|
suite.Equal(pinned, 0) // This account has nothing pinned.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (suite *AccountTestSuite) TestPopulateAccountWithUnknownMovedToURI() {
|
||||||
|
testAccount := >smodel.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) {
|
func TestAccountTestSuite(t *testing.T) {
|
||||||
suite.Run(t, new(AccountTestSuite))
|
suite.Run(t, new(AccountTestSuite))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue