Sigh, local object/actor structs have just become more complicated
This commit is contained in:
parent
bd541cc3e6
commit
ed06508b7b
10
actors.go
10
actors.go
|
@ -37,7 +37,7 @@ type Endpoints struct {
|
|||
// Actors are retrieved like any other Object in ActivityPub.
|
||||
// Like other ActivityStreams objects, actors have an id, which is a URI.
|
||||
type actor struct {
|
||||
as.Parent
|
||||
Parent
|
||||
// A reference to an [ActivityStreams] OrderedCollection comprised of all the messages received by the actor;
|
||||
// see 5.2 Inbox.
|
||||
Inbox as.Item `jsonld:"inbox,omitempty"`
|
||||
|
@ -93,7 +93,7 @@ func actorNew(id as.ObjectID, typ as.ActivityVocabularyType) *actor {
|
|||
typ = as.ActorType
|
||||
}
|
||||
|
||||
a := actor{Parent: as.Object{ID: id, Type: typ}}
|
||||
a := actor{Parent: Object{Parent: as.Parent{ID: id, Type: typ}}}
|
||||
a.Name = as.NaturalLanguageValuesNew()
|
||||
a.Content = as.NaturalLanguageValuesNew()
|
||||
a.Summary = as.NaturalLanguageValuesNew()
|
||||
|
@ -155,8 +155,12 @@ func (a *actor) UnmarshalJSON(data []byte) error {
|
|||
func ToPerson(it as.Item) (*Person, error) {
|
||||
switch i := it.(type) {
|
||||
case *as.Object:
|
||||
return &Person{Parent: *i}, nil
|
||||
return &Person{Parent: Object{Parent: *i}}, nil
|
||||
case as.Object:
|
||||
return &Person{Parent: Object{Parent: i}}, nil
|
||||
case *Object:
|
||||
return &Person{Parent: *i}, nil
|
||||
case Object:
|
||||
return &Person{Parent: i}, nil
|
||||
case *actor:
|
||||
return i, nil
|
||||
|
|
|
@ -15,11 +15,11 @@ type Source struct {
|
|||
MediaType as.MimeType `jsonld:"mediaType"`
|
||||
}
|
||||
|
||||
type Parent = as.Object
|
||||
type Parent = Object
|
||||
|
||||
// Object
|
||||
type Object struct {
|
||||
Parent
|
||||
as.Parent
|
||||
// Source property is intended to convey some sort of source from which the content markup was derived,
|
||||
// as a form of provenance, or to support future editing by clients.
|
||||
// In general, clients do the conversion from source to content, not the other way around.
|
||||
|
|
|
@ -288,11 +288,13 @@ var allTests = tests{
|
|||
expected: true,
|
||||
blank: &ap.Person{},
|
||||
result: &ap.Person{
|
||||
Parent: a.Parent{
|
||||
ID: a.ObjectID("http://example.com/accounts/ana"),
|
||||
Type: a.PersonType,
|
||||
Name: a.NaturalLanguageValues{{a.NilLangRef, "ana"}},
|
||||
URL: a.IRI("http://example.com/accounts/ana"),
|
||||
Parent: ap.Parent{
|
||||
Parent: a.Parent{
|
||||
ID: a.ObjectID("http://example.com/accounts/ana"),
|
||||
Type: a.PersonType,
|
||||
Name: a.NaturalLanguageValues{{a.NilLangRef, "ana"}},
|
||||
URL: a.IRI("http://example.com/accounts/ana"),
|
||||
},
|
||||
},
|
||||
PreferredUsername: a.NaturalLanguageValues{{a.NilLangRef, "Ana"}},
|
||||
Outbox: &a.OrderedCollection{
|
||||
|
|
|
@ -6,13 +6,13 @@ import (
|
|||
)
|
||||
|
||||
func JSONGetItemByType(typ as.ActivityVocabularyType) (as.Item, error) {
|
||||
obTyp := as.ActivityVocabularyTypes{as.ObjectType,}
|
||||
if as.ObjectTypes.Contains(typ) || obTyp.Contains(typ) {
|
||||
return &Object{Parent: Parent{Type: typ}}, nil
|
||||
obTyp := as.ActivityVocabularyTypes{as.ObjectType}
|
||||
if as.ObjectTypes.Contains(typ) || obTyp.Contains(typ) {
|
||||
return &Object{Parent: as.Object{Type: typ}}, nil
|
||||
}
|
||||
actTyp := as.ActivityVocabularyTypes{as.ActorType,}
|
||||
actTyp := as.ActivityVocabularyTypes{as.ActorType}
|
||||
if as.ActorTypes.Contains(typ) || actTyp.Contains(typ) {
|
||||
return &actor{Parent: Parent{Type: typ}}, nil
|
||||
return &actor{Parent: Parent{Parent: as.Object{Type: typ}}}, nil
|
||||
}
|
||||
return as.JSONGetItemByType(typ)
|
||||
}
|
||||
|
|
Reference in a new issue