mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 16:22:24 -05:00
[chore] reformat GetAccount() functionality, support updating accounts based on last_fetch (#1411)
* reformat GetAccount() functionality, and add UpdateAccount() function.
* use fetched_at instead of last_webfingered_at
* catch local "not found" errors. small formatting / error string changes
* remove now unused error type
* return nil when wrapping nil error
* update expected error messages
* return correct url for foss satan webfinger
* add AP model for Some_User
* normalize local domain
* return notretrievable where appropriate
* expose NewErrNotRetrievable
* ensure webfinger for new accounts searched by uri
* update local account short circuit
* allow enrich to fail for already-known accounts
* remove unused LastWebfingeredAt
* expose test maps on mock http client
* update Update test
* reformat GetAccount() functionality, and add UpdateAccount() function.
* use fetched_at instead of last_webfingered_at
* catch local "not found" errors. small formatting / error string changes
* remove nil error checks (we shouldn't be passing nil errors to newError() initializers)
* remove mutex unlock on transport init fail (it hasn't yet been locked!)
* woops add back the error wrapping to use ErrNotRetrievable
* caches were never being started... 🙈
---------
Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
This commit is contained in:
parent
a59dc855d9
commit
33aee1b1e9
50 changed files with 657 additions and 1159 deletions
|
|
@ -32,6 +32,7 @@ import (
|
|||
"github.com/stretchr/testify/suite"
|
||||
"github.com/superseriousbusiness/activity/pub"
|
||||
"github.com/superseriousbusiness/activity/streams"
|
||||
"github.com/superseriousbusiness/activity/streams/vocab"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api/activitypub/users"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/concurrency"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
|
|
@ -237,10 +238,11 @@ func (suite *InboxPostTestSuite) TestPostUnblock() {
|
|||
}
|
||||
|
||||
func (suite *InboxPostTestSuite) TestPostUpdate() {
|
||||
receivingAccount := suite.testAccounts["local_account_1"]
|
||||
updatedAccount := *suite.testAccounts["remote_account_1"]
|
||||
updatedAccount.DisplayName = "updated display name!"
|
||||
|
||||
// ad an emoji to the account; because we're serializing this remote
|
||||
// add an emoji to the account; because we're serializing this remote
|
||||
// account from our own instance, we need to cheat a bit to get the emoji
|
||||
// to work properly, just for this test
|
||||
testEmoji := >smodel.Emoji{}
|
||||
|
|
@ -251,8 +253,6 @@ func (suite *InboxPostTestSuite) TestPostUpdate() {
|
|||
asAccount, err := suite.tc.AccountToAS(context.Background(), &updatedAccount)
|
||||
suite.NoError(err)
|
||||
|
||||
receivingAccount := suite.testAccounts["local_account_1"]
|
||||
|
||||
// create an update
|
||||
update := streams.NewActivityStreamsUpdate()
|
||||
|
||||
|
|
@ -294,7 +294,14 @@ func (suite *InboxPostTestSuite) TestPostUpdate() {
|
|||
clientWorker := concurrency.NewWorkerPool[messages.FromClientAPI](-1, -1)
|
||||
fedWorker := concurrency.NewWorkerPool[messages.FromFederator](-1, -1)
|
||||
|
||||
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil, "../../../../testrig/media"), suite.db, fedWorker)
|
||||
// use a different version of the mock http client which serves the updated
|
||||
// version of the remote account, as though it had been updated there too;
|
||||
// this is needed so it can be dereferenced + updated properly
|
||||
mockHTTPClient := testrig.NewMockHTTPClient(nil, "../../../../testrig/media")
|
||||
mockHTTPClient.TestRemotePeople = map[string]vocab.ActivityStreamsPerson{
|
||||
updatedAccount.URI: asAccount,
|
||||
}
|
||||
tc := testrig.NewTestTransportController(mockHTTPClient, suite.db, fedWorker)
|
||||
federator := testrig.NewTestFederator(suite.db, tc, suite.storage, suite.mediaManager, fedWorker)
|
||||
emailSender := testrig.NewEmailSender("../../../../web/template/", nil)
|
||||
processor := testrig.NewTestProcessor(suite.db, suite.storage, federator, emailSender, suite.mediaManager, clientWorker, fedWorker)
|
||||
|
|
@ -346,8 +353,8 @@ func (suite *InboxPostTestSuite) TestPostUpdate() {
|
|||
// emojis should be updated
|
||||
suite.Contains(dbUpdatedAccount.EmojiIDs, testEmoji.ID)
|
||||
|
||||
// account should be freshly webfingered
|
||||
suite.WithinDuration(time.Now(), dbUpdatedAccount.LastWebfingeredAt, 10*time.Second)
|
||||
// account should be freshly fetched
|
||||
suite.WithinDuration(time.Now(), dbUpdatedAccount.FetchedAt, 10*time.Second)
|
||||
|
||||
// everything else should be the same as it was before
|
||||
suite.EqualValues(updatedAccount.Username, dbUpdatedAccount.Username)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue