Added ToPerson function
This commit is contained in:
parent
8b5feb3b2b
commit
c2cc81ff3b
17
actors.go
17
actors.go
|
@ -1,6 +1,9 @@
|
|||
package activitypub
|
||||
|
||||
import as "github.com/go-ap/activitystreams"
|
||||
import (
|
||||
"errors"
|
||||
as "github.com/go-ap/activitystreams"
|
||||
)
|
||||
|
||||
// Endpoints a json object which maps additional (typically server/domain-wide)
|
||||
// endpoints which may be useful either for this actor or someone referencing this actor.
|
||||
|
@ -151,3 +154,15 @@ func (a *actor)UnmarshalJSON(data []byte) error {
|
|||
//a.Streams = as.JSONGetItems(data, "streams")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
// ToObject
|
||||
func ToPerson(it as.Item) (*Person, error) {
|
||||
switch i := it.(type) {
|
||||
case *actor:
|
||||
return i, nil
|
||||
case actor:
|
||||
return &i, nil
|
||||
}
|
||||
return nil, errors.New("unable to convert object")
|
||||
}
|
||||
|
|
|
@ -333,3 +333,7 @@ func TestService_IsLink(t *testing.T) {
|
|||
func TestService_IsObject(t *testing.T) {
|
||||
t.Skipf("TODO")
|
||||
}
|
||||
|
||||
func TestToPerson(t *testing.T) {
|
||||
t.Skipf("TODO")
|
||||
}
|
||||
|
|
2
go.mod
2
go.mod
|
@ -2,6 +2,6 @@ module github.com/go-ap/activitypub
|
|||
|
||||
require (
|
||||
github.com/buger/jsonparser v0.0.0-20181023193515-52c6e1462ebd
|
||||
github.com/go-ap/activitystreams v0.0.0-20190306111705-2a794fbd6a34
|
||||
github.com/go-ap/activitystreams v0.0.0-20190512181306-9255f5ce5de3
|
||||
github.com/go-ap/jsonld v0.0.0-20190306111347-fbb94302fe92
|
||||
)
|
||||
|
|
Reference in a new issue