mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-29 15:56:16 -06:00
manuallyapprovesfollowers
This commit is contained in:
parent
9bc1e1049a
commit
9f1a01c0ce
5 changed files with 35 additions and 8 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -1274,6 +1274,7 @@ func NewTestFediPeople() map[string]ap.Accountable {
|
|||
"image/jpeg",
|
||||
URLMustParse("https://unknown-instance.com/media/some_header_filename.jpeg"),
|
||||
"image/png",
|
||||
false,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
|
@ -1416,7 +1417,8 @@ func newPerson(
|
|||
avatarURL *url.URL,
|
||||
avatarContentType string,
|
||||
headerURL *url.URL,
|
||||
headerContentType string) ap.Accountable {
|
||||
headerContentType string,
|
||||
manuallyApprovesFollowers bool) ap.Accountable {
|
||||
person := streams.NewActivityStreamsPerson()
|
||||
|
||||
// id should be the activitypub URI of this user
|
||||
|
|
@ -1489,8 +1491,9 @@ func newPerson(
|
|||
person.SetActivityStreamsUrl(urlProp)
|
||||
|
||||
// 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(manuallyApprovesFollowers)
|
||||
person.SetActivityStreamsManuallyApprovesFollowers(manuallyApprovesFollowersProp)
|
||||
|
||||
// discoverable
|
||||
// Will be shown in the profile directory.
|
||||
|
|
@ -1575,6 +1578,7 @@ func newPerson(
|
|||
headerURLProperty.AppendIRI(headerURL)
|
||||
headerImage.SetActivityStreamsUrl(headerURLProperty)
|
||||
headerProperty.AppendActivityStreamsImage(headerImage)
|
||||
person.SetActivityStreamsImage(headerProperty)
|
||||
|
||||
return person
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue