From 367bdca25093ee76b36506d8a5e6733b0aa2e2bb Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Sun, 10 Oct 2021 12:39:25 +0200 Subject: 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 --- internal/processing/processor_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'internal/processing/processor_test.go') diff --git a/internal/processing/processor_test.go b/internal/processing/processor_test.go index 1c4dfb32f..7a1db442e 100644 --- a/internal/processing/processor_test.go +++ b/internal/processing/processor_test.go @@ -69,6 +69,7 @@ type ProcessingStandardTestSuite struct { testMentions map[string]*gtsmodel.Mention testAutheds map[string]*oauth.Auth testBlocks map[string]*gtsmodel.Block + testActivities map[string]testrig.ActivityWithSignature sentHTTPRequests map[string][]byte @@ -92,6 +93,7 @@ func (suite *ProcessingStandardTestSuite) SetupSuite() { Account: suite.testAccounts["local_account_1"], }, } + suite.testActivities = testrig.NewTestActivities(suite.testAccounts) suite.testBlocks = testrig.NewTestBlocks() } @@ -149,6 +151,32 @@ func (suite *ProcessingStandardTestSuite) SetupTest() { return response, nil } + if req.URL.String() == "http://example.org/users/some_user/statuses/afaba698-5740-4e32-a702-af61aa543bc1" { + // the request is for the forwarded message + message := suite.testActivities["forwarded_message"].Activity.GetActivityStreamsObject().At(0).GetActivityStreamsNote() + messageI, err := streams.Serialize(message) + if err != nil { + panic(err) + } + messageJson, err := json.Marshal(messageI) + if err != nil { + panic(err) + } + responseType := "application/activity+json" + + reader := bytes.NewReader(messageJson) + readCloser := io.NopCloser(reader) + response := &http.Response{ + StatusCode: 200, + Body: readCloser, + ContentLength: int64(len(messageJson)), + Header: http.Header{ + "content-type": {responseType}, + }, + } + return response, nil + } + r := ioutil.NopCloser(bytes.NewReader([]byte{})) return &http.Response{ StatusCode: 200, -- cgit v1.2.3