diff options
author | 2021-10-10 12:39:25 +0200 | |
---|---|---|
committer | 2021-10-10 12:39:25 +0200 | |
commit | 367bdca25093ee76b36506d8a5e6733b0aa2e2bb (patch) | |
tree | 37b1b82ae6e9fad7e6d95b8abbb58bdb42049707 /internal/processing/fromfederator_test.go | |
parent | Derive visibility fixes (#271) (diff) | |
download | gotosocial-367bdca25093ee76b36506d8a5e6733b0aa2e2bb.tar.xz |
Handle forwarded messages (#273)
* correct path of foss_satan
* add APIri and notes
* test create forward note
* rename target => receiving account
* split up create into separate funcs
* update extractFromCtx
* tidy up from federator processing
* foss satan => http not https
* check if status in db
* mock dereference of status from IRI
* add forward message deref test
* update test with activities
* add remote_account_2 to test rig
Diffstat (limited to 'internal/processing/fromfederator_test.go')
-rw-r--r-- | internal/processing/fromfederator_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/internal/processing/fromfederator_test.go b/internal/processing/fromfederator_test.go index 4f100d4cb..09519d1d3 100644 --- a/internal/processing/fromfederator_test.go +++ b/internal/processing/fromfederator_test.go @@ -32,6 +32,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/id" "github.com/superseriousbusiness/gotosocial/internal/messages" + "github.com/superseriousbusiness/gotosocial/testrig" ) type FromFederatorTestSuite struct { @@ -486,6 +487,28 @@ func (suite *FromFederatorTestSuite) TestProcessFollowRequestUnlocked() { suite.Equal("Accept", accept.Type) } +// TestCreateStatusFromIRI checks if a forwarded status can be dereferenced by the processor. +func (suite *FromFederatorTestSuite) TestCreateStatusFromIRI() { + ctx := context.Background() + + receivingAccount := suite.testAccounts["local_account_1"] + statusCreator := suite.testAccounts["remote_account_2"] + + err := suite.processor.ProcessFromFederator(ctx, messages.FromFederator{ + APObjectType: ap.ObjectNote, + APActivityType: ap.ActivityCreate, + GTSModel: nil, // gtsmodel is nil because this is a forwarded status -- we want to dereference it using the iri + ReceivingAccount: receivingAccount, + APIri: testrig.URLMustParse("http://example.org/users/some_user/statuses/afaba698-5740-4e32-a702-af61aa543bc1"), + }) + suite.NoError(err) + + // status should now be in the database, attributed to remote_account_2 + s, err := suite.db.GetStatusByURI(context.Background(), "http://example.org/users/some_user/statuses/afaba698-5740-4e32-a702-af61aa543bc1") + suite.NoError(err) + suite.Equal(statusCreator.URI, s.AccountURI) +} + func TestFromFederatorTestSuite(t *testing.T) { suite.Run(t, &FromFederatorTestSuite{}) } |