2018-10-11 09:26:00 +00:00
|
|
|
package activitystreams
|
2017-09-11 20:45:57 +00:00
|
|
|
|
2017-09-12 15:25:07 +00:00
|
|
|
import (
|
2017-09-12 20:36:13 +00:00
|
|
|
"encoding/json"
|
2019-05-07 21:11:15 +00:00
|
|
|
"errors"
|
2018-06-09 11:06:55 +00:00
|
|
|
"fmt"
|
2018-04-10 17:56:14 +00:00
|
|
|
"sort"
|
2018-07-18 14:29:47 +00:00
|
|
|
"strings"
|
2017-09-12 20:37:34 +00:00
|
|
|
"time"
|
2018-08-15 09:05:36 +00:00
|
|
|
|
|
|
|
"github.com/buger/jsonparser"
|
2017-09-12 15:25:07 +00:00
|
|
|
)
|
|
|
|
|
2018-03-27 14:16:07 +00:00
|
|
|
// ObjectID designates an unique global identifier.
|
|
|
|
// All Objects in [ActivityStreams] should have unique global identifiers.
|
|
|
|
// ActivityPub extends this requirement; all objects distributed by the ActivityPub protocol MUST
|
|
|
|
// have unique global identifiers, unless they are intentionally transient
|
|
|
|
// (short lived activities that are not intended to be able to be looked up,
|
|
|
|
// such as some kinds of chat messages or game notifications).
|
|
|
|
// These identifiers must fall into one of the following groups:
|
|
|
|
//
|
2019-02-21 16:54:11 +00:00
|
|
|
// 1. Publicly dereferenceable URIs, such as HTTPS URIs, with their authority belonging
|
2018-03-27 14:16:07 +00:00
|
|
|
// to that of their originating server. (Publicly facing content SHOULD use HTTPS URIs).
|
|
|
|
// 2. An ID explicitly specified as the JSON null object, which implies an anonymous object
|
|
|
|
// (a part of its parent context)
|
2018-10-11 18:01:11 +00:00
|
|
|
type ObjectID IRI
|
2017-09-11 20:45:57 +00:00
|
|
|
|
|
|
|
const (
|
2018-03-25 18:54:51 +00:00
|
|
|
// ActivityBaseURI the basic URI for the activity streams namespaces
|
2018-10-18 18:19:18 +00:00
|
|
|
ActivityBaseURI = IRI("https://www.w3.org/ns/activitystreams")
|
|
|
|
ObjectType ActivityVocabularyType = "Object"
|
|
|
|
LinkType ActivityVocabularyType = "Link"
|
|
|
|
ActivityType ActivityVocabularyType = "Activity"
|
|
|
|
IntransitiveActivityType ActivityVocabularyType = "IntransitiveActivity"
|
|
|
|
ActorType ActivityVocabularyType = "Actor"
|
|
|
|
CollectionType ActivityVocabularyType = "Collection"
|
|
|
|
OrderedCollectionType ActivityVocabularyType = "OrderedCollection"
|
|
|
|
CollectionPageType ActivityVocabularyType = "CollectionPage"
|
|
|
|
OrderedCollectionPageType ActivityVocabularyType = "OrderedCollectionPage"
|
2017-09-11 21:10:56 +00:00
|
|
|
|
2018-07-18 15:39:27 +00:00
|
|
|
// Activity Pub Object Types
|
2017-10-02 09:53:09 +00:00
|
|
|
ArticleType ActivityVocabularyType = "Article"
|
|
|
|
AudioType ActivityVocabularyType = "Audio"
|
|
|
|
DocumentType ActivityVocabularyType = "Document"
|
|
|
|
EventType ActivityVocabularyType = "Event"
|
|
|
|
ImageType ActivityVocabularyType = "Image"
|
|
|
|
NoteType ActivityVocabularyType = "Note"
|
|
|
|
PageType ActivityVocabularyType = "Page"
|
|
|
|
PlaceType ActivityVocabularyType = "Place"
|
|
|
|
ProfileType ActivityVocabularyType = "Profile"
|
|
|
|
RelationshipType ActivityVocabularyType = "Relationship"
|
|
|
|
TombstoneType ActivityVocabularyType = "Tombstone"
|
|
|
|
VideoType ActivityVocabularyType = "Video"
|
2017-09-11 20:45:57 +00:00
|
|
|
|
2018-03-27 14:16:07 +00:00
|
|
|
// MentionType is a link type for @mentions
|
2017-10-02 09:53:09 +00:00
|
|
|
MentionType ActivityVocabularyType = "Mention"
|
2017-09-11 20:45:57 +00:00
|
|
|
)
|
|
|
|
|
2018-08-06 11:09:24 +00:00
|
|
|
const (
|
2018-08-31 11:38:15 +00:00
|
|
|
NilLangRef LangRef = "-"
|
2018-08-06 11:09:24 +00:00
|
|
|
)
|
|
|
|
|
2019-05-16 09:08:27 +00:00
|
|
|
var GenericObjectTypes = ActivityVocabularyTypes{
|
2017-09-16 10:31:23 +00:00
|
|
|
ActivityType,
|
|
|
|
IntransitiveActivityType,
|
|
|
|
ObjectType,
|
|
|
|
ActorType,
|
2017-09-16 18:20:33 +00:00
|
|
|
CollectionType,
|
|
|
|
OrderedCollectionType,
|
2017-09-16 10:31:23 +00:00
|
|
|
}
|
|
|
|
|
2019-05-16 09:08:27 +00:00
|
|
|
var GenericLinkTypes = ActivityVocabularyTypes{
|
2017-10-02 09:53:09 +00:00
|
|
|
LinkType,
|
|
|
|
}
|
|
|
|
|
2019-05-16 09:08:27 +00:00
|
|
|
var GenericTypes = append(GenericObjectTypes[:], GenericLinkTypes[:]...)
|
2017-10-02 09:53:09 +00:00
|
|
|
|
2019-05-16 09:08:27 +00:00
|
|
|
var ObjectTypes = ActivityVocabularyTypes{
|
2017-09-11 20:45:57 +00:00
|
|
|
ArticleType,
|
|
|
|
AudioType,
|
|
|
|
DocumentType,
|
|
|
|
EventType,
|
|
|
|
ImageType,
|
|
|
|
NoteType,
|
|
|
|
PageType,
|
|
|
|
PlaceType,
|
|
|
|
ProfileType,
|
|
|
|
RelationshipType,
|
|
|
|
TombstoneType,
|
|
|
|
VideoType,
|
|
|
|
}
|
2017-09-11 21:10:56 +00:00
|
|
|
|
2017-09-16 18:10:41 +00:00
|
|
|
type (
|
2018-03-27 14:16:07 +00:00
|
|
|
// ActivityVocabularyType is the data type for an Activity type object
|
2017-10-02 09:53:09 +00:00
|
|
|
ActivityVocabularyType string
|
2018-07-18 15:39:27 +00:00
|
|
|
// ActivityObject is a subtype of Object that describes some form of action that may happen,
|
2018-10-18 09:48:02 +00:00
|
|
|
// is currently happening, or has already happened
|
2018-07-24 21:11:08 +00:00
|
|
|
ActivityObject interface {
|
2019-02-21 16:54:11 +00:00
|
|
|
// GetID returns the dereferenceable ActivityStreams object id
|
2018-07-25 09:47:03 +00:00
|
|
|
GetID() *ObjectID
|
2018-07-18 19:34:08 +00:00
|
|
|
}
|
2019-02-21 16:54:11 +00:00
|
|
|
// LinkOrURI is an interface that Object and Link structs implement, and at the same time
|
|
|
|
// they are kept disjointed
|
|
|
|
LinkOrURI interface {
|
|
|
|
// GetLink returns the object id in IRI type
|
|
|
|
GetLink() IRI
|
|
|
|
}
|
|
|
|
// Item describes the requirements of an ActivityStreams object
|
2018-03-25 18:54:51 +00:00
|
|
|
ObjectOrLink interface {
|
2018-07-13 08:15:14 +00:00
|
|
|
ActivityObject
|
2018-10-11 19:47:31 +00:00
|
|
|
LinkOrURI
|
2019-02-21 16:54:11 +00:00
|
|
|
// GetType returns the ActivityStreams type
|
2018-06-09 12:05:46 +00:00
|
|
|
GetType() ActivityVocabularyType
|
2019-02-21 16:54:11 +00:00
|
|
|
// IsLink shows if current object represents a link object or an IRI
|
2018-07-18 19:34:08 +00:00
|
|
|
IsLink() bool
|
2019-02-21 16:54:11 +00:00
|
|
|
// IsObject shows if current object represents an ActivityStrems object
|
2018-07-18 19:34:08 +00:00
|
|
|
IsObject() bool
|
2018-07-18 14:29:47 +00:00
|
|
|
//UnmarshalJSON([]byte) error
|
2017-10-02 13:59:48 +00:00
|
|
|
}
|
2019-02-21 16:54:11 +00:00
|
|
|
// Mapper interface allows external objects to implement their own mechanism for loading information
|
|
|
|
// from an ActivityStreams vocabulary object
|
|
|
|
Mapper interface {
|
|
|
|
// FromActivityStreams maps an ActivityStreams object to another struct representation
|
|
|
|
FromActivityStreams(Item) error
|
2018-07-13 08:15:14 +00:00
|
|
|
}
|
2019-02-21 16:54:11 +00:00
|
|
|
|
|
|
|
// MimeType is the type for representing MIME types in certain ActivityStreams properties
|
2018-03-25 18:54:51 +00:00
|
|
|
MimeType string
|
2019-02-21 16:54:11 +00:00
|
|
|
// LangRef is the type for a language reference code, should be an ISO639-1 language specifier.
|
2018-03-25 18:54:51 +00:00
|
|
|
LangRef string
|
2018-09-02 13:41:53 +00:00
|
|
|
|
2019-02-21 16:54:11 +00:00
|
|
|
// LangRefValue is a type for storing per language values
|
2018-09-02 13:41:53 +00:00
|
|
|
LangRefValue struct {
|
|
|
|
Ref LangRef
|
|
|
|
Value string
|
|
|
|
}
|
2019-02-21 16:54:11 +00:00
|
|
|
// NaturalLanguageValues is a mapping for multiple language values
|
|
|
|
NaturalLanguageValues []LangRefValue
|
2017-09-16 18:10:41 +00:00
|
|
|
)
|
2017-09-12 15:25:07 +00:00
|
|
|
|
2019-02-21 16:54:11 +00:00
|
|
|
func NaturalLanguageValuesNew() NaturalLanguageValues {
|
|
|
|
return make(NaturalLanguageValues, 0)
|
2018-09-02 13:41:53 +00:00
|
|
|
}
|
|
|
|
|
2019-02-21 16:54:11 +00:00
|
|
|
func (n NaturalLanguageValues) Get(ref LangRef) string {
|
2018-09-02 13:41:53 +00:00
|
|
|
for _, val := range n {
|
|
|
|
if val.Ref == ref {
|
|
|
|
return val.Value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2019-02-21 16:54:11 +00:00
|
|
|
// Set sets a language, value pair in a NaturalLanguageValues array
|
|
|
|
func (n *NaturalLanguageValues) Set(ref LangRef, v string) error {
|
|
|
|
found := false
|
|
|
|
for k, vv := range *n {
|
|
|
|
if vv.Ref == ref {
|
|
|
|
(*n)[k] = LangRefValue{ref, v}
|
|
|
|
found = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if !found {
|
|
|
|
n.Append(ref, v)
|
|
|
|
}
|
2018-09-02 13:41:53 +00:00
|
|
|
return nil
|
|
|
|
}
|
2018-09-06 14:07:45 +00:00
|
|
|
|
2018-07-18 15:39:27 +00:00
|
|
|
// IsLink validates if currentActivity Pub Object is a Link
|
2018-06-09 12:05:46 +00:00
|
|
|
func (o Object) IsLink() bool {
|
|
|
|
return false
|
2017-10-02 09:53:09 +00:00
|
|
|
}
|
|
|
|
|
2018-07-18 15:39:27 +00:00
|
|
|
// IsObject validates if currentActivity Pub Object is an Object
|
2018-06-09 12:05:46 +00:00
|
|
|
func (o Object) IsObject() bool {
|
|
|
|
return true
|
2017-10-02 09:53:09 +00:00
|
|
|
}
|
|
|
|
|
2019-02-21 16:54:11 +00:00
|
|
|
// MarshalJSON serializes the NaturalLanguageValues into JSON
|
|
|
|
func (n NaturalLanguageValues) MarshalJSON() ([]byte, error) {
|
2018-09-02 13:41:53 +00:00
|
|
|
if len(n) == 0 {
|
|
|
|
return json.Marshal(nil)
|
|
|
|
}
|
2017-09-16 18:10:41 +00:00
|
|
|
if len(n) == 1 {
|
|
|
|
for _, v := range n {
|
2018-09-02 13:41:53 +00:00
|
|
|
return json.Marshal(v.Value)
|
2017-09-12 20:37:34 +00:00
|
|
|
}
|
|
|
|
}
|
2018-09-02 13:41:53 +00:00
|
|
|
mm := make(map[LangRef]string)
|
|
|
|
for _, val := range n {
|
|
|
|
mm[val.Ref] = val.Value
|
|
|
|
}
|
2017-09-12 20:36:13 +00:00
|
|
|
|
2018-09-02 13:41:53 +00:00
|
|
|
return json.Marshal(mm)
|
2017-09-12 20:36:13 +00:00
|
|
|
}
|
|
|
|
|
2019-02-21 16:54:11 +00:00
|
|
|
// First returns the first element in the array
|
|
|
|
func (n NaturalLanguageValues) First() string {
|
2018-07-25 09:47:41 +00:00
|
|
|
for _, v := range n {
|
2018-09-02 13:41:53 +00:00
|
|
|
return v.Value
|
2018-07-25 09:47:41 +00:00
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2019-02-21 16:54:11 +00:00
|
|
|
// MarshalText serializes the NaturalLanguageValues into Text
|
|
|
|
func (n NaturalLanguageValues) MarshalText() ([]byte, error) {
|
2018-07-24 21:11:08 +00:00
|
|
|
for _, v := range n {
|
|
|
|
return []byte(fmt.Sprintf("%q", v)), nil
|
|
|
|
}
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2019-02-21 16:54:11 +00:00
|
|
|
// Append is syntactic sugar for resizing the NaturalLanguageValues map
|
2018-10-18 09:48:02 +00:00
|
|
|
// and appending an element
|
2019-02-21 16:54:11 +00:00
|
|
|
func (n *NaturalLanguageValues) Append(lang LangRef, value string) error {
|
|
|
|
var t NaturalLanguageValues
|
2018-06-07 14:32:26 +00:00
|
|
|
if len(*n) == 0 {
|
2019-02-21 16:54:11 +00:00
|
|
|
t = make(NaturalLanguageValues, 0)
|
2018-06-07 14:32:26 +00:00
|
|
|
} else {
|
|
|
|
t = *n
|
|
|
|
}
|
2018-09-02 13:41:53 +00:00
|
|
|
t = append(*n, LangRefValue{lang, value})
|
2018-06-07 14:32:26 +00:00
|
|
|
*n = t
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalJSON tries to load the NaturalLanguage array from the incoming json value
|
|
|
|
func (l *LangRef) UnmarshalJSON(data []byte) error {
|
2018-11-10 20:57:47 +00:00
|
|
|
return l.UnmarshalText(data)
|
2018-06-07 14:32:26 +00:00
|
|
|
}
|
|
|
|
|
2018-07-24 21:11:08 +00:00
|
|
|
// UnmarshalText tries to load the NaturalLanguage array from the incoming Text value
|
|
|
|
func (l *LangRef) UnmarshalText(data []byte) error {
|
2018-11-10 20:57:47 +00:00
|
|
|
*l = LangRef("")
|
|
|
|
if len(data) == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
if len(data) > 2 {
|
|
|
|
if data[0] == '"' && data[len(data)-1] == '"' {
|
|
|
|
*l = LangRef(data[1 : len(data)-1])
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
*l = LangRef(data)
|
|
|
|
}
|
2018-07-24 21:11:08 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-06-07 14:32:26 +00:00
|
|
|
// UnmarshalJSON tries to load the NaturalLanguage array from the incoming json value
|
2019-02-21 16:54:11 +00:00
|
|
|
func (n *NaturalLanguageValues) UnmarshalJSON(data []byte) error {
|
2018-08-31 11:40:42 +00:00
|
|
|
val, typ, _, err := jsonparser.Get(data)
|
|
|
|
if err != nil {
|
2018-12-16 12:19:19 +00:00
|
|
|
// try our luck if data contains an unquoted string
|
|
|
|
n.Append(NilLangRef, string(data))
|
2018-08-31 11:40:42 +00:00
|
|
|
return nil
|
2018-07-24 21:11:08 +00:00
|
|
|
}
|
2018-08-31 11:40:42 +00:00
|
|
|
switch typ {
|
|
|
|
case jsonparser.Object:
|
|
|
|
jsonparser.ObjectEach(data, func(key []byte, value []byte, dataType jsonparser.ValueType, offset int) error {
|
|
|
|
n.Append(LangRef(key), string(value))
|
|
|
|
return err
|
|
|
|
})
|
|
|
|
case jsonparser.String:
|
|
|
|
n.Append(NilLangRef, string(val))
|
2018-06-09 11:06:55 +00:00
|
|
|
}
|
2018-08-31 11:40:42 +00:00
|
|
|
|
2018-06-07 14:32:26 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-07-24 21:11:08 +00:00
|
|
|
// UnmarshalText tries to load the NaturalLanguage array from the incoming Text value
|
2019-02-21 16:54:11 +00:00
|
|
|
func (n *NaturalLanguageValues) UnmarshalText(data []byte) error {
|
2018-07-24 21:11:08 +00:00
|
|
|
if data[0] == '"' {
|
|
|
|
// a quoted string - loading it to c.URL
|
|
|
|
if data[len(data)-1] != '"' {
|
|
|
|
return fmt.Errorf("invalid string value when unmarshalling %T value", n)
|
|
|
|
}
|
2018-08-31 11:38:15 +00:00
|
|
|
n.Append(LangRef(NilLangRef), string(data[1:len(data)-1]))
|
2018-07-24 21:11:08 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-11-23 14:22:56 +00:00
|
|
|
type object struct {
|
2018-10-24 09:28:55 +00:00
|
|
|
// ID provides the globally unique identifier for anActivity Pub Object or Link.
|
2018-04-08 16:55:25 +00:00
|
|
|
ID ObjectID `jsonld:"id,omitempty"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// Type identifies the Activity Pub Object or Link type. Multiple values may be specified.
|
2017-10-02 09:53:09 +00:00
|
|
|
Type ActivityVocabularyType `jsonld:"type,omitempty"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// Name a simple, human-readable, plain-text name for the object.
|
2017-09-12 15:25:07 +00:00
|
|
|
// HTML markup MUST NOT be included. The name MAY be expressed using multiple language-tagged values.
|
2019-02-21 16:54:11 +00:00
|
|
|
Name NaturalLanguageValues `jsonld:"name,omitempty,collapsible"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// Attachment identifies a resource attached or related to an object that potentially requires special handling.
|
2017-09-12 15:25:07 +00:00
|
|
|
// The intent is to provide a model that is at least semantically similar to attachments in email.
|
2018-10-04 18:33:32 +00:00
|
|
|
Attachment Item `jsonld:"attachment,omitempty"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// AttributedTo identifies one or more entities to which this object is attributed. The attributed entities might not be Actors.
|
2017-09-12 15:25:07 +00:00
|
|
|
// For instance, an object might be attributed to the completion of another activity.
|
2018-10-04 18:33:32 +00:00
|
|
|
AttributedTo Item `jsonld:"attributedTo,omitempty"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// Audience identifies one or more entities that represent the total population of entities
|
2018-10-18 09:48:02 +00:00
|
|
|
// for which the object can considered to be relevant.
|
2019-05-04 22:15:23 +00:00
|
|
|
Audience ItemCollection `jsonld:"audience,omitempty"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// Content or textual representation of the Activity Pub Object encoded as a JSON string.
|
2017-09-12 15:25:07 +00:00
|
|
|
// By default, the value of content is HTML.
|
|
|
|
// The mediaType property can be used in the object to indicate a different content type.
|
|
|
|
// (The content MAY be expressed using multiple language-tagged values.)
|
2019-02-21 16:54:11 +00:00
|
|
|
Content NaturalLanguageValues `jsonld:"content,omitempty,collapsible"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// Context identifies the context within which the object exists or an activity was performed.
|
2017-09-12 15:25:07 +00:00
|
|
|
// The notion of "context" used is intentionally vague.
|
|
|
|
// The intended function is to serve as a means of grouping objects and activities that share a
|
2018-10-18 09:48:02 +00:00
|
|
|
// common originating context or purpose. An example could be all activities relating to a common project or event.
|
2018-10-04 18:33:32 +00:00
|
|
|
Context Item `jsonld:"context,omitempty"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// MediaType when used on an Object, identifies the MIME media type of the value of the content property.
|
2018-07-18 14:19:50 +00:00
|
|
|
// If not specified, the content property is assumed to contain text/html content.
|
|
|
|
MediaType MimeType `jsonld:"mediaType,omitempty"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// EndTime the date and time describing the actual or expected ending time of the object.
|
2017-09-12 15:25:07 +00:00
|
|
|
// When used with an Activity object, for instance, the endTime property specifies the moment
|
2018-10-18 09:48:02 +00:00
|
|
|
// the activity concluded or is expected to conclude.
|
2017-10-02 09:53:09 +00:00
|
|
|
EndTime time.Time `jsonld:"endTime,omitempty"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// Generator identifies the entity (e.g. an application) that generated the object.
|
2018-10-04 18:33:32 +00:00
|
|
|
Generator Item `jsonld:"generator,omitempty"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// Icon indicates an entity that describes an icon for this object.
|
2017-09-12 15:25:07 +00:00
|
|
|
// The image should have an aspect ratio of one (horizontal) to one (vertical)
|
2018-10-18 09:48:02 +00:00
|
|
|
// and should be suitable for presentation at a small size.
|
2018-10-11 19:47:31 +00:00
|
|
|
Icon Item `jsonld:"icon,omitempty"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// Image indicates an entity that describes an image for this object.
|
2017-09-12 15:25:07 +00:00
|
|
|
// Unlike the icon property, there are no aspect ratio or display size limitations assumed.
|
2018-10-11 19:47:31 +00:00
|
|
|
Image Item `jsonld:"image,omitempty"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// InReplyTo indicates one or more entities for which this object is considered a response.
|
2018-10-04 18:33:32 +00:00
|
|
|
InReplyTo Item `jsonld:"inReplyTo,omitempty"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// Location indicates one or more physical or logical locations associated with the object.
|
2018-10-04 18:33:32 +00:00
|
|
|
Location Item `jsonld:"location,omitempty"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// Preview identifies an entity that provides a preview of this object.
|
2018-10-04 18:33:32 +00:00
|
|
|
Preview Item `jsonld:"preview,omitempty"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// Published the date and time at which the object was published
|
2017-10-02 09:53:09 +00:00
|
|
|
Published time.Time `jsonld:"published,omitempty"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// Replies identifies a Collection containing objects considered to be responses to this object.
|
2018-10-04 18:33:32 +00:00
|
|
|
Replies Item `jsonld:"replies,omitempty"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// StartTime the date and time describing the actual or expected starting time of the object.
|
2017-09-12 15:25:07 +00:00
|
|
|
// When used with an Activity object, for instance, the startTime property specifies
|
2018-10-18 09:48:02 +00:00
|
|
|
// the moment the activity began or is scheduled to begin.
|
2017-10-02 09:53:09 +00:00
|
|
|
StartTime time.Time `jsonld:"startTime,omitempty"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// Summary a natural language summarization of the object encoded as HTML.
|
2017-09-12 15:25:07 +00:00
|
|
|
// *Multiple language tagged summaries may be provided.)
|
2019-02-21 16:54:11 +00:00
|
|
|
Summary NaturalLanguageValues `jsonld:"summary,omitempty,collapsible"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// Tag one or more "tags" that have been associated with an objects. A tag can be any kind of Activity Pub Object.
|
2017-09-12 15:25:07 +00:00
|
|
|
// The key difference between attachment and tag is that the former implies association by inclusion,
|
2018-10-18 09:48:02 +00:00
|
|
|
// while the latter implies associated by reference.
|
2018-11-14 11:51:35 +00:00
|
|
|
Tag ItemCollection `jsonld:"tag,omitempty"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// Updated the date and time at which the object was updated
|
2017-10-02 09:53:09 +00:00
|
|
|
Updated time.Time `jsonld:"updated,omitempty"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// URL identifies one or more links to representations of the object
|
2018-04-10 15:53:05 +00:00
|
|
|
URL LinkOrURI `jsonld:"url,omitempty"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// To identifies an entity considered to be part of the public primary audience of an Activity Pub Object
|
2018-10-04 18:33:32 +00:00
|
|
|
To ItemCollection `jsonld:"to,omitempty"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// Bto identifies anActivity Pub Object that is part of the private primary audience of this Activity Pub Object.
|
2018-10-04 18:33:32 +00:00
|
|
|
Bto ItemCollection `jsonld:"bto,omitempty"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// CC identifies anActivity Pub Object that is part of the public secondary audience of this Activity Pub Object.
|
2018-10-04 18:33:32 +00:00
|
|
|
CC ItemCollection `jsonld:"cc,omitempty"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// BCC identifies one or more Objects that are part of the private secondary audience of this Activity Pub Object.
|
2018-10-04 18:33:32 +00:00
|
|
|
BCC ItemCollection `jsonld:"bcc,omitempty"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// Duration when the object describes a time-bound resource, such as an audio or video, a meeting, etc,
|
2018-10-18 09:48:02 +00:00
|
|
|
// the duration property indicates the object's approximate duration.
|
2017-09-12 15:25:07 +00:00
|
|
|
// The value must be expressed as an xsd:duration as defined by [ xmlschema11-2],
|
2018-10-18 09:48:02 +00:00
|
|
|
// section 3.3.6 (e.g. a period of 5 seconds is represented as "PT5S").
|
2017-10-02 09:53:09 +00:00
|
|
|
Duration time.Duration `jsonld:"duration,omitempty"`
|
2017-09-12 15:25:07 +00:00
|
|
|
}
|
|
|
|
|
2018-10-11 19:10:17 +00:00
|
|
|
type (
|
2018-11-23 14:22:56 +00:00
|
|
|
Parent = object
|
|
|
|
// Describes an object of any kind.
|
|
|
|
// The Activity Pub Object type serves as the base type for most of the other kinds of objects defined in the Activity Vocabulary,
|
|
|
|
// including other Core types such as Activity, IntransitiveActivity, Collection and OrderedCollection.
|
|
|
|
Object = object
|
2018-10-24 09:28:55 +00:00
|
|
|
// Article represents any kind of multi-paragraph written work.
|
2019-01-30 19:50:50 +00:00
|
|
|
Article = Object
|
2018-10-24 09:28:55 +00:00
|
|
|
// Audio represents an audio document of any kind.
|
2019-01-30 19:50:50 +00:00
|
|
|
Audio = Document
|
2018-10-24 09:28:55 +00:00
|
|
|
// Document represents a document of any kind.
|
2019-01-30 19:50:50 +00:00
|
|
|
Document = Object
|
2018-10-24 09:28:55 +00:00
|
|
|
// Event represents any kind of event.
|
2019-01-30 19:50:50 +00:00
|
|
|
Event = Object
|
2018-10-11 19:10:17 +00:00
|
|
|
// Image An image document of any kind
|
2019-01-30 19:50:50 +00:00
|
|
|
Image = Document
|
2018-10-24 09:28:55 +00:00
|
|
|
// Note represents a short written work typically less than a single paragraph in length.
|
2019-01-30 19:50:50 +00:00
|
|
|
Note = Object
|
2018-10-24 09:28:55 +00:00
|
|
|
// Page represents a Web Page.
|
2019-01-30 19:50:50 +00:00
|
|
|
Page = Document
|
2018-10-24 09:28:55 +00:00
|
|
|
// Video represents a video document of any kind
|
2019-01-30 19:50:50 +00:00
|
|
|
Video = Document
|
2018-10-11 19:10:17 +00:00
|
|
|
)
|
|
|
|
|
2018-10-24 09:28:55 +00:00
|
|
|
// Place represents a logical or physical location. See 5.3 Representing Places for additional information.
|
2018-10-11 19:10:17 +00:00
|
|
|
type Place struct {
|
2018-11-23 14:22:56 +00:00
|
|
|
Parent
|
2018-10-24 09:28:55 +00:00
|
|
|
// Accuracy indicates the accuracy of position coordinates on a Place objects.
|
2018-10-11 19:10:17 +00:00
|
|
|
// Expressed in properties of percentage. e.g. "94.0" means "94.0% accurate".
|
|
|
|
Accuracy float32
|
2018-10-24 09:28:55 +00:00
|
|
|
// Altitude indicates the altitude of a place. The measurement units is indicated using the units property.
|
2018-10-11 19:10:17 +00:00
|
|
|
// If units is not specified, the default is assumed to be "m" indicating meters.
|
|
|
|
Altitude float32
|
2018-10-24 09:28:55 +00:00
|
|
|
// Latitude the latitude of a place
|
2018-10-11 19:10:17 +00:00
|
|
|
Latitude float32
|
2018-10-24 09:28:55 +00:00
|
|
|
// Longitude the longitude of a place
|
2018-10-11 19:10:17 +00:00
|
|
|
Longitude float32
|
2018-10-24 09:28:55 +00:00
|
|
|
// Radius the radius from the given latitude and longitude for a Place.
|
2018-10-11 19:10:17 +00:00
|
|
|
// The units is expressed by the units property. If units is not specified,
|
|
|
|
// the default is assumed to be "m" indicating "meters".
|
|
|
|
Radius int
|
|
|
|
// Specifies the measurement units for the radius and altitude properties on a Place object.
|
|
|
|
// If not specified, the default is assumed to be "m" for "meters".
|
|
|
|
// Values "cm" | " feet" | " inches" | " km" | " m" | " miles" | xsd:anyURI
|
|
|
|
Units string
|
|
|
|
}
|
|
|
|
|
2018-10-24 09:28:55 +00:00
|
|
|
// Profile a Profile is a content object that describes another Object,
|
2018-10-11 19:10:17 +00:00
|
|
|
// typically used to describe Actor Type objects.
|
2018-10-24 09:28:55 +00:00
|
|
|
// The describes property is used to reference the object being described by the profile.
|
2018-10-11 19:10:17 +00:00
|
|
|
type Profile struct {
|
2018-11-23 14:22:56 +00:00
|
|
|
Parent
|
2018-10-11 19:10:17 +00:00
|
|
|
// Describes On a Profile object, the describes property identifies the object described by the Profile.
|
|
|
|
Describes Item `jsonld:"describes,omitempty"`
|
|
|
|
}
|
|
|
|
|
2018-10-24 09:28:55 +00:00
|
|
|
// Relationship describes a relationship between two individuals.
|
2018-10-11 19:10:17 +00:00
|
|
|
// The subject and object properties are used to identify the connected individuals.
|
|
|
|
//See 5.2 Representing Relationships Between Entities for additional information.
|
|
|
|
// 5.2: The relationship property specifies the kind of relationship that exists between the two individuals identified
|
|
|
|
// by the subject and object properties. Used together, these three properties form what is commonly known
|
|
|
|
// as a "reified statement" where subject identifies the subject, relationship identifies the predicate,
|
|
|
|
// and object identifies the object.
|
|
|
|
type Relationship struct {
|
2018-11-23 14:22:56 +00:00
|
|
|
Parent
|
2018-10-24 09:28:55 +00:00
|
|
|
// Subject Subject On a Relationship object, the subject property identifies one of the connected individuals.
|
2018-10-11 19:10:17 +00:00
|
|
|
// For instance, for a Relationship object describing "John is related to Sally", subject would refer to John.
|
|
|
|
Subject Item
|
|
|
|
// Object
|
|
|
|
Object Item
|
|
|
|
// Relationship On a Relationship object, the relationship property identifies the kind
|
|
|
|
// of relationship that exists between subject and object.
|
|
|
|
Relationship Item
|
|
|
|
}
|
|
|
|
|
2018-10-24 09:28:55 +00:00
|
|
|
// Tombstone a Tombstone represents a content object that has been deleted.
|
2018-10-11 19:10:17 +00:00
|
|
|
// It can be used in Collections to signify that there used to be an object at this position,
|
|
|
|
// but it has been deleted.
|
|
|
|
type Tombstone struct {
|
2018-11-23 14:22:56 +00:00
|
|
|
Parent
|
2018-10-11 19:10:17 +00:00
|
|
|
// FormerType On a Tombstone object, the formerType property identifies the type of the object that was deleted.
|
2018-12-16 12:19:19 +00:00
|
|
|
FormerType ActivityVocabularyType `jsonld:"formerType,omitempty"`
|
2018-10-11 19:10:17 +00:00
|
|
|
// Deleted On a Tombstone object, the deleted property is a timestamp for when the object was deleted.
|
2018-12-16 12:19:19 +00:00
|
|
|
Deleted time.Time `jsonld:"deleted,omitempty"`
|
2018-10-11 19:10:17 +00:00
|
|
|
}
|
|
|
|
|
2018-07-18 15:39:27 +00:00
|
|
|
// ObjectNew initializes a new Object
|
2018-10-11 09:26:00 +00:00
|
|
|
func ObjectNew(typ ActivityVocabularyType) *Object {
|
2019-05-16 09:08:27 +00:00
|
|
|
if !(ObjectTypes.Contains(typ)) {
|
2018-06-09 12:05:46 +00:00
|
|
|
typ = ObjectType
|
2017-09-11 20:45:57 +00:00
|
|
|
}
|
2018-10-11 09:26:00 +00:00
|
|
|
o := Object{Type: typ}
|
2019-02-21 16:54:11 +00:00
|
|
|
o.Name = NaturalLanguageValuesNew()
|
|
|
|
o.Content = NaturalLanguageValuesNew()
|
2018-06-09 12:05:46 +00:00
|
|
|
return &o
|
2017-09-11 20:45:57 +00:00
|
|
|
}
|
2018-04-08 16:10:54 +00:00
|
|
|
|
2018-07-18 15:39:27 +00:00
|
|
|
// GetID returns the ObjectID corresponding to the current object
|
2018-07-25 09:47:03 +00:00
|
|
|
func (o Object) GetID() *ObjectID {
|
|
|
|
return &o.ID
|
2018-04-08 16:10:54 +00:00
|
|
|
}
|
|
|
|
|
2018-10-11 18:48:38 +00:00
|
|
|
// GetLink returns the IRI corresponding to the current object
|
2018-10-11 18:13:34 +00:00
|
|
|
func (o Object) GetLink() IRI {
|
|
|
|
return IRI(o.ID)
|
|
|
|
}
|
|
|
|
|
2018-07-18 15:39:27 +00:00
|
|
|
// Link returns the Link corresponding to the current object
|
2018-06-09 12:05:46 +00:00
|
|
|
func (o Object) GetType() ActivityVocabularyType {
|
|
|
|
return o.Type
|
2018-04-08 16:10:54 +00:00
|
|
|
}
|
2018-04-10 15:53:05 +00:00
|
|
|
|
2018-06-09 12:05:46 +00:00
|
|
|
// recipientsDeduplication normalizes the received arguments lists
|
2018-10-04 18:33:32 +00:00
|
|
|
func recipientsDeduplication(recArgs ...*ItemCollection) error {
|
2018-04-10 15:53:05 +00:00
|
|
|
recIds := make([]ObjectID, 0)
|
|
|
|
|
2018-04-10 17:56:14 +00:00
|
|
|
for _, recList := range recArgs {
|
|
|
|
if recList == nil {
|
2018-04-10 15:53:05 +00:00
|
|
|
continue
|
|
|
|
}
|
2018-04-10 18:09:06 +00:00
|
|
|
|
2018-04-10 17:56:14 +00:00
|
|
|
toRemove := make([]int, 0)
|
|
|
|
for i, rec := range *recList {
|
2018-04-10 15:53:05 +00:00
|
|
|
save := true
|
2018-09-06 14:07:45 +00:00
|
|
|
if rec == nil {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
var testId ObjectID
|
|
|
|
if rec.IsObject() {
|
|
|
|
testId = *rec.GetID()
|
|
|
|
} else if rec.IsLink() {
|
|
|
|
testId = ObjectID(rec.(IRI))
|
|
|
|
} else {
|
|
|
|
continue
|
|
|
|
}
|
2018-04-10 15:53:05 +00:00
|
|
|
for _, id := range recIds {
|
2018-09-06 14:07:45 +00:00
|
|
|
if testId == id {
|
2018-04-10 17:56:14 +00:00
|
|
|
// mark the element for removal
|
|
|
|
toRemove = append(toRemove, i)
|
2018-04-10 15:53:05 +00:00
|
|
|
save = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if save {
|
2018-09-06 14:07:45 +00:00
|
|
|
recIds = append(recIds, testId)
|
2018-04-10 15:53:05 +00:00
|
|
|
}
|
|
|
|
}
|
2018-04-10 17:56:14 +00:00
|
|
|
|
|
|
|
sort.Sort(sort.Reverse(sort.IntSlice(toRemove)))
|
|
|
|
for _, idx := range toRemove {
|
2018-04-10 18:09:06 +00:00
|
|
|
*recList = append((*recList)[:idx], (*recList)[idx+1:]...)
|
2018-04-10 17:56:14 +00:00
|
|
|
}
|
2018-04-10 15:53:05 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2018-06-15 21:03:55 +00:00
|
|
|
|
2018-07-18 14:29:47 +00:00
|
|
|
// UnmarshalJSON
|
|
|
|
func (i *ObjectID) UnmarshalJSON(data []byte) error {
|
|
|
|
*i = ObjectID(strings.Trim(string(data), "\""))
|
2018-06-15 21:03:55 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-07-18 14:29:47 +00:00
|
|
|
// UnmarshalJSON
|
2018-11-21 11:25:12 +00:00
|
|
|
func (c *MimeType) UnmarshalJSON(data []byte) error {
|
|
|
|
*c = MimeType(strings.Trim(string(data), "\""))
|
2018-06-15 21:03:55 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-07-24 21:11:08 +00:00
|
|
|
// UnmarshalJSON
|
|
|
|
func (o *Object) UnmarshalJSON(data []byte) error {
|
2019-05-18 20:45:54 +00:00
|
|
|
if ItemTyperFunc == nil {
|
|
|
|
ItemTyperFunc = JSONGetItemByType
|
|
|
|
}
|
2019-01-30 15:19:29 +00:00
|
|
|
o.ID = JSONGetObjectID(data)
|
|
|
|
o.Type = JSONGetType(data)
|
|
|
|
o.Name = JSONGetNaturalLanguageField(data, "name")
|
|
|
|
o.Content = JSONGetNaturalLanguageField(data, "content")
|
|
|
|
o.Summary = JSONGetNaturalLanguageField(data, "summary")
|
|
|
|
o.Context = JSONGetItem(data, "context")
|
|
|
|
o.URL = JSONGetURIItem(data, "url")
|
|
|
|
o.MediaType = MimeType(JSONGetString(data, "mediaType"))
|
|
|
|
o.Generator = JSONGetItem(data, "generator")
|
|
|
|
o.AttributedTo = JSONGetItem(data, "attributedTo")
|
|
|
|
o.InReplyTo = JSONGetItem(data, "inReplyTo")
|
2019-05-04 22:15:23 +00:00
|
|
|
o.Attachment = JSONGetItem(data, "attachment")
|
|
|
|
o.Location = JSONGetItem(data, "location")
|
2019-01-30 15:19:29 +00:00
|
|
|
o.Published = JSONGetTime(data, "published")
|
|
|
|
o.StartTime = JSONGetTime(data, "startTime")
|
|
|
|
o.EndTime = JSONGetTime(data, "endTime")
|
|
|
|
o.Duration = JSONGetDuration(data, "duration")
|
|
|
|
o.Icon = JSONGetItem(data, "icon")
|
2019-05-04 22:15:23 +00:00
|
|
|
o.Preview = JSONGetItem(data, "preview")
|
2019-01-30 15:19:29 +00:00
|
|
|
o.Image = JSONGetItem(data, "image")
|
|
|
|
o.Updated = JSONGetTime(data, "updated")
|
|
|
|
to := JSONGetItems(data, "to")
|
2018-08-31 15:56:18 +00:00
|
|
|
if to != nil {
|
|
|
|
o.To = to
|
|
|
|
}
|
2019-05-04 22:15:23 +00:00
|
|
|
audience := JSONGetItems(data, "audience")
|
|
|
|
if audience != nil {
|
|
|
|
o.Audience = audience
|
|
|
|
}
|
2019-01-30 15:19:29 +00:00
|
|
|
bto := JSONGetItems(data, "bto")
|
2018-12-08 13:17:47 +00:00
|
|
|
if bto != nil {
|
|
|
|
o.Bto = bto
|
|
|
|
}
|
2019-01-30 15:19:29 +00:00
|
|
|
cc := JSONGetItems(data, "cc")
|
2018-12-08 13:17:47 +00:00
|
|
|
if cc != nil {
|
|
|
|
o.CC = cc
|
|
|
|
}
|
2019-01-30 15:19:29 +00:00
|
|
|
bcc := JSONGetItems(data, "bcc")
|
2018-12-08 13:17:47 +00:00
|
|
|
if bcc != nil {
|
|
|
|
o.BCC = bcc
|
|
|
|
}
|
2019-01-30 15:19:29 +00:00
|
|
|
replies := JSONGetItem(data, "replies")
|
2018-12-02 15:50:40 +00:00
|
|
|
if replies != nil {
|
|
|
|
o.Replies = replies
|
2018-08-15 09:05:36 +00:00
|
|
|
}
|
2019-01-30 15:19:29 +00:00
|
|
|
tag := JSONGetItems(data, "tag")
|
2018-11-14 12:42:04 +00:00
|
|
|
if tag != nil {
|
|
|
|
o.Tag = tag
|
|
|
|
}
|
2018-07-24 21:11:08 +00:00
|
|
|
return nil
|
|
|
|
}
|
2019-05-04 22:52:14 +00:00
|
|
|
|
|
|
|
// ToObject
|
2019-05-07 21:11:15 +00:00
|
|
|
func ToObject(it Item) (*Object, error) {
|
2019-05-04 22:52:14 +00:00
|
|
|
switch i := it.(type) {
|
|
|
|
case *Object:
|
2019-05-07 21:11:15 +00:00
|
|
|
return i, nil
|
2019-05-04 22:52:14 +00:00
|
|
|
case Object:
|
2019-05-07 21:11:15 +00:00
|
|
|
return &i, nil
|
2019-05-05 12:30:26 +00:00
|
|
|
case *Place:
|
2019-05-07 21:11:15 +00:00
|
|
|
return &i.Parent, nil
|
2019-05-05 12:30:26 +00:00
|
|
|
case Place:
|
2019-05-07 21:11:15 +00:00
|
|
|
return &i.Parent, nil
|
2019-05-05 12:30:26 +00:00
|
|
|
case *Profile:
|
2019-05-07 21:11:15 +00:00
|
|
|
return &i.Parent, nil
|
2019-05-05 12:30:26 +00:00
|
|
|
case Profile:
|
2019-05-07 21:11:15 +00:00
|
|
|
return &i.Parent, nil
|
2019-05-05 12:30:26 +00:00
|
|
|
case *Relationship:
|
2019-05-07 21:11:15 +00:00
|
|
|
return &i.Parent, nil
|
2019-05-05 12:30:26 +00:00
|
|
|
case Relationship:
|
2019-05-07 21:11:15 +00:00
|
|
|
return &i.Parent, nil
|
2019-05-05 12:30:26 +00:00
|
|
|
case *Tombstone:
|
2019-05-07 21:11:15 +00:00
|
|
|
return &i.Parent, nil
|
2019-05-05 12:30:26 +00:00
|
|
|
case Tombstone:
|
2019-05-07 21:11:15 +00:00
|
|
|
return &i.Parent, nil
|
2019-05-04 22:52:14 +00:00
|
|
|
}
|
2019-05-07 21:11:15 +00:00
|
|
|
return nil, errors.New("unable to convert object")
|
2019-05-04 22:52:14 +00:00
|
|
|
}
|
2019-05-11 08:31:19 +00:00
|
|
|
|
2019-05-11 09:53:32 +00:00
|
|
|
// FlattenObjectProperties flattens the Object's properties from Object types to IRI
|
|
|
|
func FlattenObjectProperties(o Object) Object {
|
2019-05-11 08:31:19 +00:00
|
|
|
if o.Replies != nil && o.Replies.IsObject() {
|
|
|
|
if len(o.Replies.GetLink()) > 0 {
|
|
|
|
o.Replies = o.Replies.GetLink()
|
|
|
|
} else {
|
|
|
|
o.Replies = IRI(fmt.Sprintf("%s/replies", o.GetLink()))
|
|
|
|
}
|
|
|
|
}
|
2019-05-11 09:53:32 +00:00
|
|
|
o.AttributedTo = FlattenToIRI(o.AttributedTo)
|
|
|
|
o.InReplyTo = FlattenToIRI(o.InReplyTo)
|
2019-05-11 08:31:19 +00:00
|
|
|
|
2019-05-11 09:53:32 +00:00
|
|
|
o.To = FlattenItemCollection(o.To)
|
|
|
|
o.Bto = FlattenItemCollection(o.Bto)
|
|
|
|
o.CC = FlattenItemCollection(o.CC)
|
|
|
|
o.BCC = FlattenItemCollection(o.BCC)
|
|
|
|
o.Audience = FlattenItemCollection(o.Audience)
|
2019-05-11 08:31:19 +00:00
|
|
|
|
2019-05-11 09:53:32 +00:00
|
|
|
o.Tag = FlattenItemCollection(o.Tag)
|
2019-05-11 08:31:19 +00:00
|
|
|
|
|
|
|
return o
|
|
|
|
}
|
|
|
|
|
2019-05-11 09:53:32 +00:00
|
|
|
// FlattenProperties flattens the Item's properties from Object types to IRI
|
|
|
|
func FlattenProperties(it Item) Item {
|
2019-05-16 09:08:27 +00:00
|
|
|
if ActivityTypes.Contains(it.GetType()) {
|
2019-05-11 08:31:19 +00:00
|
|
|
act, err := ToActivity(it)
|
|
|
|
if err == nil {
|
2019-05-11 09:53:32 +00:00
|
|
|
return FlattenActivityProperties(*act)
|
2019-05-11 08:31:19 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-16 09:08:27 +00:00
|
|
|
if ActorTypes.Contains(it.GetType()) || ObjectTypes.Contains(it.GetType()) {
|
2019-05-11 08:31:19 +00:00
|
|
|
ob, err := ToObject(it)
|
|
|
|
if err == nil {
|
2019-05-11 09:53:32 +00:00
|
|
|
return FlattenObjectProperties(*ob)
|
2019-05-11 08:31:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return it
|
|
|
|
}
|
2019-05-12 18:13:06 +00:00
|
|
|
|
|
|
|
// UnmarshalJSON
|
|
|
|
func (t *Tombstone) UnmarshalJSON(data []byte) error {
|
|
|
|
t.Parent.UnmarshalJSON(data)
|
|
|
|
t.FormerType = ActivityVocabularyType(JSONGetString(data, "formerType"))
|
|
|
|
t.Deleted = JSONGetTime(data, "deleted")
|
|
|
|
return nil
|
|
|
|
}
|