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"
|
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:
|
|
|
|
//
|
|
|
|
// 1. Publicly dereferencable URIs, such as HTTPS URIs, with their authority belonging
|
|
|
|
// 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
|
|
|
)
|
|
|
|
|
2017-10-02 09:53:09 +00:00
|
|
|
var validGenericObjectTypes = [...]ActivityVocabularyType{
|
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
|
|
|
}
|
|
|
|
|
2017-10-02 09:53:09 +00:00
|
|
|
var validGenericLinkTypes = [...]ActivityVocabularyType{
|
|
|
|
LinkType,
|
|
|
|
}
|
|
|
|
|
|
|
|
var validGenericTypes = append(validGenericObjectTypes[:], validGenericLinkTypes[:]...)
|
|
|
|
|
|
|
|
var validObjectTypes = [...]ActivityVocabularyType{
|
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 {
|
2018-07-25 09:47:03 +00:00
|
|
|
GetID() *ObjectID
|
2018-07-18 19:34:08 +00:00
|
|
|
}
|
2018-10-04 18:33:32 +00:00
|
|
|
// Item describes an object of any kind.
|
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
|
2018-06-09 12:05:46 +00:00
|
|
|
GetType() ActivityVocabularyType
|
2018-07-18 19:34:08 +00:00
|
|
|
IsLink() bool
|
|
|
|
IsObject() bool
|
2018-07-18 14:29:47 +00:00
|
|
|
//UnmarshalJSON([]byte) error
|
2017-10-02 13:59:48 +00:00
|
|
|
}
|
2018-07-18 15:39:27 +00:00
|
|
|
// LinkOrURI is an interface that Object and Link structs implement, and at the same time
|
2018-03-27 14:16:07 +00:00
|
|
|
// they are kept disjointed
|
2018-07-18 14:29:47 +00:00
|
|
|
LinkOrURI interface {
|
2018-10-11 18:13:34 +00:00
|
|
|
GetLink() IRI
|
2018-07-13 08:15:14 +00:00
|
|
|
}
|
2018-03-27 14:16:07 +00:00
|
|
|
// MimeType is the type for MIME types
|
2018-03-25 18:54:51 +00:00
|
|
|
MimeType string
|
2018-03-27 14:16:07 +00:00
|
|
|
// LangRef is the type for a language reference, should be ISO 639-1 language specifier.
|
2018-03-25 18:54:51 +00:00
|
|
|
LangRef string
|
2018-09-02 13:41:53 +00:00
|
|
|
|
|
|
|
LangRefValue struct {
|
|
|
|
Ref LangRef
|
|
|
|
Value string
|
|
|
|
}
|
2018-03-27 14:16:07 +00:00
|
|
|
// NaturalLanguageValue is a mapping for multiple language values
|
2018-09-02 13:41:53 +00:00
|
|
|
NaturalLanguageValue []LangRefValue
|
2017-09-16 18:10:41 +00:00
|
|
|
)
|
2017-09-12 15:25:07 +00:00
|
|
|
|
2018-09-02 13:41:53 +00:00
|
|
|
func NaturalLanguageValueNew() NaturalLanguageValue {
|
|
|
|
return make(NaturalLanguageValue, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (n NaturalLanguageValue) Get(ref LangRef) string {
|
|
|
|
for _, val := range n {
|
|
|
|
if val.Ref == ref {
|
|
|
|
return val.Value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func (n *NaturalLanguageValue) Set(ref LangRef, v string) error {
|
|
|
|
t := append(*n, LangRefValue{ref, v})
|
|
|
|
*n = t
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-03-25 18:54:51 +00:00
|
|
|
// MarshalJSON serializes the NaturalLanguageValue into JSON
|
2017-09-16 18:10:41 +00:00
|
|
|
func (n NaturalLanguageValue) 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
|
|
|
}
|
|
|
|
|
2018-07-25 09:47:41 +00:00
|
|
|
// First returns the first element in the map
|
|
|
|
func (n NaturalLanguageValue) First() string {
|
|
|
|
for _, v := range n {
|
2018-09-02 13:41:53 +00:00
|
|
|
return v.Value
|
2018-07-25 09:47:41 +00:00
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2018-07-24 21:11:08 +00:00
|
|
|
// MarshalText serializes the NaturalLanguageValue into Text
|
|
|
|
func (n NaturalLanguageValue) MarshalText() ([]byte, error) {
|
|
|
|
for _, v := range n {
|
|
|
|
return []byte(fmt.Sprintf("%q", v)), nil
|
|
|
|
}
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2018-06-07 14:32:26 +00:00
|
|
|
// Append is syntactic sugar for resizing the NaturalLanguageValue map
|
2018-10-18 09:48:02 +00:00
|
|
|
// and appending an element
|
2018-06-07 14:32:26 +00:00
|
|
|
func (n *NaturalLanguageValue) Append(lang LangRef, value string) error {
|
|
|
|
var t NaturalLanguageValue
|
|
|
|
if len(*n) == 0 {
|
|
|
|
t = make(NaturalLanguageValue, 1)
|
|
|
|
} 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
|
|
|
|
func (n *NaturalLanguageValue) UnmarshalJSON(data []byte) error {
|
2018-08-31 11:40:42 +00:00
|
|
|
val, typ, _, err := jsonparser.Get(data)
|
|
|
|
if err != nil {
|
|
|
|
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
|
|
|
|
func (n *NaturalLanguageValue) UnmarshalText(data []byte) error {
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2017-09-12 15:25:07 +00:00
|
|
|
// Describes an object of any kind.
|
2018-07-18 15:39:27 +00:00
|
|
|
// The Activity Pub Object type serves as the base type for most of the other kinds of objects defined in the Activity Vocabulary,
|
2018-10-18 09:48:02 +00:00
|
|
|
// including other Core types such as Activity, IntransitiveActivity, Collection and OrderedCollection.
|
2018-06-09 12:05:46 +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.
|
2017-10-02 09:53:09 +00:00
|
|
|
Name NaturalLanguageValue `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.
|
2018-10-04 18:33:32 +00:00
|
|
|
Audience Item `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.)
|
2017-10-02 09:53:09 +00:00
|
|
|
Content NaturalLanguageValue `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.)
|
2017-10-02 09:53:09 +00:00
|
|
|
Summary NaturalLanguageValue `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-10-24 09:28:55 +00:00
|
|
|
// Article represents any kind of multi-paragraph written work.
|
2018-10-11 19:10:17 +00:00
|
|
|
Article Object
|
2018-10-24 09:28:55 +00:00
|
|
|
// Audio represents an audio document of any kind.
|
2018-10-11 19:10:17 +00:00
|
|
|
Audio Document
|
2018-10-24 09:28:55 +00:00
|
|
|
// Document represents a document of any kind.
|
2018-10-11 19:10:17 +00:00
|
|
|
Document Object
|
2018-10-24 09:28:55 +00:00
|
|
|
// Event represents any kind of event.
|
2018-10-11 19:10:17 +00:00
|
|
|
Event Object
|
|
|
|
// Image An image document of any kind
|
|
|
|
Image Document
|
2018-10-24 09:28:55 +00:00
|
|
|
// Note represents a short written work typically less than a single paragraph in length.
|
2018-10-11 19:10:17 +00:00
|
|
|
Note Object
|
2018-10-24 09:28:55 +00:00
|
|
|
// Page represents a Web Page.
|
2018-10-11 19:10:17 +00:00
|
|
|
Page Document
|
2018-10-24 09:28:55 +00:00
|
|
|
// Video represents a video document of any kind
|
2018-10-11 19:10:17 +00:00
|
|
|
Video Document
|
|
|
|
)
|
|
|
|
|
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 {
|
|
|
|
Object
|
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 {
|
|
|
|
Object
|
|
|
|
// 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-10-24 09:28:55 +00:00
|
|
|
// ID provides the globally unique identifier for anActivity Pub Object or Link.
|
2018-10-11 19:10:17 +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.
|
2018-10-11 19:10:17 +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.
|
2018-10-11 19:10:17 +00:00
|
|
|
// HTML markup MUST NOT be included. The name MAY be expressed using multiple language-tagged values.
|
|
|
|
Name NaturalLanguageValue `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.
|
2018-10-11 19:10:17 +00:00
|
|
|
// The intent is to provide a model that is at least semantically similar to attachments in email.
|
|
|
|
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.
|
2018-10-11 19:10:17 +00:00
|
|
|
// For instance, an object might be attributed to the completion of another activity.
|
|
|
|
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.
|
2018-10-11 19:10:17 +00:00
|
|
|
Audience Item `jsonld:"audience,omitempty"`
|
2018-10-24 09:28:55 +00:00
|
|
|
// Content the content or textual representation of the Activity Pub Object encoded as a JSON string.
|
2018-10-11 19:10:17 +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.)
|
|
|
|
Content NaturalLanguageValue `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.
|
2018-10-11 19:10:17 +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-11 19:10:17 +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-10-11 19:10:17 +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.
|
2018-10-11 19:10:17 +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.
|
2018-10-11 19:10:17 +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-11 19:10:17 +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.
|
2018-10-11 19:10:17 +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.
|
2018-10-11 19:10:17 +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-11 19:10:17 +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-11 19:10:17 +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-11 19:10:17 +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
|
2018-10-11 19:10:17 +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-11 19:10:17 +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.
|
2018-10-11 19:10:17 +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.
|
2018-10-11 19:10:17 +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.
|
2018-10-11 19:10:17 +00:00
|
|
|
// *Multiple language tagged summaries may be provided.)
|
|
|
|
Summary NaturalLanguageValue `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.
|
2018-10-11 19:10:17 +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
|
2018-10-11 19:10:17 +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-10-11 19:10:17 +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-11 19:10:17 +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-11 19:10:17 +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-11 19:10:17 +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-11 19:10:17 +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.
|
2018-10-11 19:10:17 +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").
|
2018-10-11 19:10:17 +00:00
|
|
|
Duration time.Duration `jsonld:"duration,omitempty"`
|
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 {
|
|
|
|
Object
|
|
|
|
// FormerType On a Tombstone object, the formerType property identifies the type of the object that was deleted.
|
|
|
|
FormerType Item
|
|
|
|
// Deleted On a Tombstone object, the deleted property is a timestamp for when the object was deleted.
|
|
|
|
Deleted time.Time
|
|
|
|
}
|
|
|
|
|
2018-03-27 14:16:07 +00:00
|
|
|
// ContentType represents the content type for a Source object
|
2017-09-11 20:45:57 +00:00
|
|
|
type ContentType string
|
2017-09-11 21:10:56 +00:00
|
|
|
|
2018-03-25 18:54:51 +00:00
|
|
|
// ValidGenericType validates the type against the valid generic object types
|
2018-06-09 12:05:46 +00:00
|
|
|
func ValidGenericType(typ ActivityVocabularyType) bool {
|
2017-10-02 09:53:09 +00:00
|
|
|
for _, v := range validGenericObjectTypes {
|
2018-06-09 12:05:46 +00:00
|
|
|
if v == typ {
|
2017-09-15 16:11:31 +00:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2018-03-25 18:54:51 +00:00
|
|
|
// ValidObjectType validates the type against the valid object types
|
2018-06-09 12:05:46 +00:00
|
|
|
func ValidObjectType(typ ActivityVocabularyType) bool {
|
2017-09-11 20:45:57 +00:00
|
|
|
for _, v := range validObjectTypes {
|
2018-06-09 12:05:46 +00:00
|
|
|
if v == typ {
|
2017-09-11 20:45:57 +00:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
2018-06-09 12:05:46 +00:00
|
|
|
return ValidActivityType(typ) || ValidActorType(typ) || ValidCollectionType(typ) || ValidGenericType(typ)
|
2017-09-11 20:45:57 +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 {
|
2018-06-09 12:05:46 +00:00
|
|
|
if !(ValidObjectType(typ)) {
|
|
|
|
typ = ObjectType
|
2017-09-11 20:45:57 +00:00
|
|
|
}
|
2018-10-11 09:26:00 +00:00
|
|
|
o := Object{Type: typ}
|
2018-09-02 13:41:53 +00:00
|
|
|
o.Name = NaturalLanguageValueNew()
|
|
|
|
o.Content = NaturalLanguageValueNew()
|
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
|
|
|
|
func (c *ContentType) UnmarshalJSON(data []byte) error {
|
|
|
|
*c = ContentType(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 {
|
|
|
|
o.ID = getAPObjectID(data)
|
|
|
|
o.Type = getAPType(data)
|
|
|
|
o.Name = getAPNaturalLanguageField(data, "name")
|
|
|
|
o.Content = getAPNaturalLanguageField(data, "content")
|
2018-10-04 16:27:14 +00:00
|
|
|
o.Context = getAPItem(data, "context")
|
2018-10-31 15:26:51 +00:00
|
|
|
o.URL = getURIField(data, "url")
|
2018-08-05 14:33:51 +00:00
|
|
|
o.MediaType = MimeType(getAPString(data, "mediaType"))
|
2018-08-06 11:06:14 +00:00
|
|
|
o.Generator = getAPItem(data, "generator")
|
|
|
|
o.AttributedTo = getAPItem(data, "attributedTo")
|
2018-08-31 15:56:18 +00:00
|
|
|
o.InReplyTo = getAPItem(data, "inReplyTo")
|
2018-08-06 17:11:24 +00:00
|
|
|
o.Published = getAPTime(data, "published")
|
|
|
|
o.StartTime = getAPTime(data, "startTime")
|
|
|
|
o.Updated = getAPTime(data, "updated")
|
2018-10-04 18:33:32 +00:00
|
|
|
to := getAPItemCollection(data, "to")
|
2018-08-31 15:56:18 +00:00
|
|
|
if to != nil {
|
|
|
|
o.To = to
|
|
|
|
}
|
2018-08-15 09:33:50 +00:00
|
|
|
if v, _, _, err := jsonparser.Get(data, "replies"); err == nil {
|
|
|
|
r := Collection{}
|
|
|
|
if r.UnmarshalJSON(v) == nil {
|
|
|
|
o.Replies = &r
|
|
|
|
}
|
2018-08-15 09:05:36 +00:00
|
|
|
}
|
2018-11-14 12:42:04 +00:00
|
|
|
tag := getAPItemCollection(data, "tag")
|
|
|
|
if tag != nil {
|
|
|
|
o.Tag = tag
|
|
|
|
}
|
2018-07-24 21:11:08 +00:00
|
|
|
return nil
|
|
|
|
}
|