diff options
author | 2021-08-23 12:46:05 +0200 | |
---|---|---|
committer | 2021-08-23 12:46:05 +0200 | |
commit | 071eca20ce9527153ed2e549f6198aad32380495 (patch) | |
tree | 958c75f403655b5fedabb20f5e431386798f02b2 /internal | |
parent | Database updates (#144) (diff) | |
download | gotosocial-071eca20ce9527153ed2e549f6198aad32380495.tar.xz |
Manually approves followers (#146)
* update go-fed
* update go-fed
* manuallyapprovesfollowers
* serialize manuallyApprovesFollowers
Diffstat (limited to 'internal')
-rw-r--r-- | internal/ap/interfaces.go | 6 | ||||
-rw-r--r-- | internal/gtsmodel/account.go | 2 | ||||
-rw-r--r-- | internal/typeutils/astointernal.go | 7 | ||||
-rw-r--r-- | internal/typeutils/astointernal_test.go | 18 | ||||
-rw-r--r-- | internal/typeutils/internaltoas.go | 4 |
5 files changed, 31 insertions, 6 deletions
diff --git a/internal/ap/interfaces.go b/internal/ap/interfaces.go index 43dd149d5..a20f39bd2 100644 --- a/internal/ap/interfaces.go +++ b/internal/ap/interfaces.go @@ -39,6 +39,7 @@ type Accountable interface { WithFollowing WithFollowers WithFeatured + WithManuallyApprovesFollowers } // Statusable represents the minimum activitypub interface for representing a 'status'. @@ -319,3 +320,8 @@ type WithPartOf interface { type WithItems interface { GetActivityStreamsItems() vocab.ActivityStreamsItemsProperty } + +// WithManuallyApprovesFollowers represents a Person or profile with the ManuallyApprovesFollowers property. +type WithManuallyApprovesFollowers interface { + GetActivityStreamsManuallyApprovesFollowers() vocab.ActivityStreamsManuallyApprovesFollowersProperty +} diff --git a/internal/gtsmodel/account.go b/internal/gtsmodel/account.go index 435caea6d..9673dcb2c 100644 --- a/internal/gtsmodel/account.go +++ b/internal/gtsmodel/account.go @@ -78,7 +78,7 @@ type Account struct { */ // Does this account need an approval for new followers? - Locked bool `pg:",default:true"` + Locked bool `pg:",default:true,use_zero"` // Should this account be shown in the instance's profile directory? Discoverable bool `pg:",default:false"` // Default post privacy for this account diff --git a/internal/typeutils/astointernal.go b/internal/typeutils/astointernal.go index a16318df8..887716a69 100644 --- a/internal/typeutils/astointernal.go +++ b/internal/typeutils/astointernal.go @@ -105,7 +105,12 @@ func (c *converter) ASRepresentationToAccount(accountable ap.Accountable, update } acct.ActorType = accountable.GetTypeName() - // TODO: locked aka manuallyApprovesFollowers + // locked aka manuallyApprovesFollowers + acct.Locked = true // assume locked by default + maf := accountable.GetActivityStreamsManuallyApprovesFollowers() + if maf != nil && maf.IsXMLSchemaBoolean() { + acct.Locked = maf.Get() + } // discoverable // default to false -- take custom value if it's set though diff --git a/internal/typeutils/astointernal_test.go b/internal/typeutils/astointernal_test.go index 5b8e30134..1d02dec5a 100644 --- a/internal/typeutils/astointernal_test.go +++ b/internal/typeutils/astointernal_test.go @@ -346,14 +346,26 @@ func (suite *ASToInternalTestSuite) SetupTest() { } func (suite *ASToInternalTestSuite) TestParsePerson() { - testPerson := suite.people["new_person_1"] acct, err := suite.typeconverter.ASRepresentationToAccount(testPerson, false) assert.NoError(suite.T(), err) - fmt.Printf("%+v", acct) - // TODO: write assertions here, rn we're just eyeballing the output + suite.Equal("https://unknown-instance.com/users/brand_new_person", acct.URI) + 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.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) + suite.Equal("Geoff Brando New Personson", acct.DisplayName) + suite.Equal("hey I'm a new person, your instance hasn't seen me yet uwu", acct.Note) + suite.Equal("https://unknown-instance.com/@brand_new_person", acct.URL) + suite.True(acct.Discoverable) + suite.Equal("https://unknown-instance.com/users/brand_new_person#main-key", acct.PublicKeyURI) + suite.Equal("https://unknown-instance.com/media/some_avatar_filename.jpeg", acct.AvatarRemoteURL) + suite.Equal("https://unknown-instance.com/media/some_header_filename.jpeg", acct.HeaderRemoteURL) + suite.False(acct.Locked) } func (suite *ASToInternalTestSuite) TestParseGargron() { diff --git a/internal/typeutils/internaltoas.go b/internal/typeutils/internaltoas.go index 11ace9dfa..178567dc6 100644 --- a/internal/typeutils/internaltoas.go +++ b/internal/typeutils/internaltoas.go @@ -143,7 +143,9 @@ func (c *converter) AccountToAS(a *gtsmodel.Account) (vocab.ActivityStreamsPerso // manuallyApprovesFollowers // Will be shown as a locked account. - // TODO: NOT IMPLEMENTED **YET** -- this needs to be added as an activitypub extension to https://github.com/go-fed/activity, see https://github.com/go-fed/activity/tree/master/astool + manuallyApprovesFollowersProp := streams.NewActivityStreamsManuallyApprovesFollowersProperty() + manuallyApprovesFollowersProp.Set(a.Locked) + person.SetActivityStreamsManuallyApprovesFollowers(manuallyApprovesFollowersProp) // discoverable // Will be shown in the profile directory. |