This repository has been archived on 2022-11-27. You can view files and clone it, but cannot push or open issues or pull requests.
activitypub/unmarshall.go

48 lines
798 B
Go

package activitypub
import (
as "github.com/go-ap/activitystreams"
)
func JSONGetItemByType(typ as.ActivityVocabularyType) (as.Item, error) {
var ret as.Item
var err error
switch typ {
case as.ObjectType:
o := &Object{}
o.Type = typ
ret = o
case as.ActorType:
o := &actor{}
o.Type = typ
ret = o
case as.ApplicationType:
a := &Application{}
a.Type = typ
ret = a
case as.GroupType:
g := &Group{}
g.Type = typ
ret = g
case as.OrganizationType:
o := &Organization{}
o.Type = typ
ret = o
case as.PersonType:
p := &Person{}
p.Type = typ
ret = p
case as.ServiceType:
s := &Service{}
s.Type = typ
ret = s
case "":
// when no type is available use a plain Object
ret = &Object{}
default:
return as.JSONGetItemByType(typ)
}
return ret, err
}