From 69a193dae543641a2db6823fa6493c02f56fafbd Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Fri, 23 Sep 2022 21:27:35 +0200 Subject: [feature] Allow delivery to sharedInboxes where possible (#847) * update Activity * add instance-deliver-to-shared-inboxes setting * update activity version again * add SharedInboxURI field to accounts * serdes for endpoints/sharedInbox * deliver to sharedInbox if one is available * update tests * only assign shared inbox if shared domain * look for shared inbox if currently nil * go fmt * finger to get params.RemoteAccountID if necessary * make comments clearer * compare dns more consistently --- internal/typeutils/astointernal_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'internal/typeutils/astointernal_test.go') diff --git a/internal/typeutils/astointernal_test.go b/internal/typeutils/astointernal_test.go index 7024018d6..9273405e6 100644 --- a/internal/typeutils/astointernal_test.go +++ b/internal/typeutils/astointernal_test.go @@ -45,6 +45,7 @@ func (suite *ASToInternalTestSuite) TestParsePerson() { suite.Equal("https://unknown-instance.com/users/brand_new_person/following", acct.FollowingURI) suite.Equal("https://unknown-instance.com/users/brand_new_person/followers", acct.FollowersURI) suite.Equal("https://unknown-instance.com/users/brand_new_person/inbox", acct.InboxURI) + suite.Nil(acct.SharedInboxURI) suite.Equal("https://unknown-instance.com/users/brand_new_person/outbox", acct.OutboxURI) suite.Equal("https://unknown-instance.com/users/brand_new_person/collections/featured", acct.FeaturedCollectionURI) suite.Equal("brand_new_person", acct.Username) @@ -56,6 +57,28 @@ func (suite *ASToInternalTestSuite) TestParsePerson() { suite.False(*acct.Locked) } +func (suite *ASToInternalTestSuite) TestParsePersonWithSharedInbox() { + testPerson := suite.testPeople["https://turnip.farm/users/turniplover6969"] + + acct, err := suite.typeconverter.ASRepresentationToAccount(context.Background(), testPerson, "", false) + suite.NoError(err) + + suite.Equal("https://turnip.farm/users/turniplover6969", acct.URI) + suite.Equal("https://turnip.farm/users/turniplover6969/following", acct.FollowingURI) + suite.Equal("https://turnip.farm/users/turniplover6969/followers", acct.FollowersURI) + suite.Equal("https://turnip.farm/users/turniplover6969/inbox", acct.InboxURI) + suite.Equal("https://turnip.farm/sharedInbox", *acct.SharedInboxURI) + suite.Equal("https://turnip.farm/users/turniplover6969/outbox", acct.OutboxURI) + suite.Equal("https://turnip.farm/users/turniplover6969/collections/featured", acct.FeaturedCollectionURI) + suite.Equal("turniplover6969", acct.Username) + suite.Equal("Turnip Lover 6969", acct.DisplayName) + suite.Equal("I just think they're neat", acct.Note) + suite.Equal("https://turnip.farm/@turniplover6969", acct.URL) + suite.True(*acct.Discoverable) + suite.Equal("https://turnip.farm/users/turniplover6969#main-key", acct.PublicKeyURI) + suite.False(*acct.Locked) +} + func (suite *ASToInternalTestSuite) TestParsePublicStatus() { m := make(map[string]interface{}) err := json.Unmarshal([]byte(publicStatusActivityJson), &m) @@ -109,6 +132,8 @@ func (suite *ASToInternalTestSuite) TestParseGargron() { acct, err := suite.typeconverter.ASRepresentationToAccount(context.Background(), rep, "", false) suite.NoError(err) + suite.Equal("https://mastodon.social/inbox", *acct.SharedInboxURI) + fmt.Printf("%+v", acct) // TODO: write assertions here, rn we're just eyeballing the output } -- cgit v1.2.3