Changes
11 changed files (+72/-72)
-
-
@@ -67,7 +67,7 @@ var validActivityTypes = [...]ActivityVocabularyType{// Instances of IntransitiveActivity are a subtype of Activity representing intransitive actions. // The object property is therefore inappropriate for these activities. type IntransitiveActivity struct { *Object *APObject // Describes one or more entities that either performed or are expected to perform the activity. // Any single activity can have multiple actors. The actor may be specified using an indirect Link. Actor Actor `jsonld:"actor,omitempty"`
-
@@ -89,7 +89,7 @@ type IntransitiveActivity struct {Source Source `jsonld:"source,omitempty"` } // An Activity is a subtype of Object that describes some form of action that may happen, // An Activity is a subtype of APObject that describes some form of action that may happen, // is currently happening, or has already happened. // The Activity type itself serves as an abstract base type for all types of activities. // It is important to note that the Activity type itself does not carry any specific semantics
-
@@ -382,7 +382,7 @@ func ActivityNew(id ObjectId, _type ActivityVocabularyType, ob *ObjectOrLink) *A_type = ActivityType } o := ObjectNew(id, _type) i := IntransitiveActivity{Object: o} i := IntransitiveActivity{APObject: o} a := Activity{IntransitiveActivity: &i} a.Object = ob
-
@@ -396,5 +396,5 @@ func IntransitiveActivityNew(id ObjectId, _type ActivityVocabularyType) *Intrans} o := ObjectNew(id, _type) return &IntransitiveActivity{Object: o} return &IntransitiveActivity{APObject: o} }
-
-
-
@@ -55,7 +55,7 @@ func TestValidActivityType(t *testing.T) {} for _, inValidType := range validObjectTypes { if ValidActivityType(inValidType) { t.Errorf("Object Type '%v' should be invalid", inValidType) t.Errorf("APObject Type '%v' should be invalid", inValidType) } } if ValidActivityType(invalidType) {
-
-
-
@@ -40,9 +40,9 @@ type Endpoints struct {SharedInbox ObjectOrLink `jsonld:"sharedInbox,omitempty"` } // Actor types are Object types that are capable of performing activities. // Actor types are APObject types that are capable of performing activities. type Actor struct { *Object *APObject // A reference to an [ActivityStreams] OrderedCollection comprised of all the messages received by the actor; // see 5.2 Inbox. Inbox InboxStream `jsonld:"inbox,omitempty"`
-
@@ -100,7 +100,7 @@ func ActorNew(id ObjectId, _type ActivityVocabularyType) *Actor {_type = ActorType } o := ObjectNew(id, _type) a := Actor{Object: o} a := Actor{APObject: o} a.PreferredUsername = make(NaturalLanguageValue, 0) return &a }
-
-
-
@@ -11,18 +11,18 @@ func TestActorNew(t *testing.T) {o := ActorNew(testValue, testType) if o.Id != testValue { t.Errorf("Object Id '%v' different than expected '%v'", o.Id, testValue) t.Errorf("APObject Id '%v' different than expected '%v'", o.Id, testValue) } if o.Type != testType { t.Errorf("Object Type '%v' different than expected '%v'", o.Type, testType) t.Errorf("APObject Type '%v' different than expected '%v'", o.Type, testType) } n := ActorNew(testValue, "") if n.Id != testValue { t.Errorf("Object Id '%v' different than expected '%v'", n.Id, testValue) t.Errorf("APObject Id '%v' different than expected '%v'", n.Id, testValue) } if n.Type != ActorType { t.Errorf("Object Type '%v' different than expected '%v'", n.Type, ActorType) t.Errorf("APObject Type '%v' different than expected '%v'", n.Type, ActorType) } }
-
@@ -31,10 +31,10 @@ func TestPersonNew(t *testing.T) {o := PersonNew(testValue) if o.Id != testValue { t.Errorf("Object Id '%v' different than expected '%v'", o.Id, testValue) t.Errorf("APObject Id '%v' different than expected '%v'", o.Id, testValue) } if o.Type != PersonType { t.Errorf("Object Type '%v' different than expected '%v'", o.Type, PersonType) t.Errorf("APObject Type '%v' different than expected '%v'", o.Type, PersonType) } }
-
@@ -43,10 +43,10 @@ func TestApplicationNew(t *testing.T) {o := ApplicationNew(testValue) if o.Id != testValue { t.Errorf("Object Id '%v' different than expected '%v'", o.Id, testValue) t.Errorf("APObject Id '%v' different than expected '%v'", o.Id, testValue) } if o.Type != ApplicationType { t.Errorf("Object Type '%v' different than expected '%v'", o.Type, ApplicationType) t.Errorf("APObject Type '%v' different than expected '%v'", o.Type, ApplicationType) } }
-
@@ -55,10 +55,10 @@ func TestGroupNew(t *testing.T) {o := GroupNew(testValue) if o.Id != testValue { t.Errorf("Object Id '%v' different than expected '%v'", o.Id, testValue) t.Errorf("APObject Id '%v' different than expected '%v'", o.Id, testValue) } if o.Type != GroupType { t.Errorf("Object Type '%v' different than expected '%v'", o.Type, GroupType) t.Errorf("APObject Type '%v' different than expected '%v'", o.Type, GroupType) } }
-
@@ -67,10 +67,10 @@ func TestOrganizationNew(t *testing.T) {o := OrganizationNew(testValue) if o.Id != testValue { t.Errorf("Object Id '%v' different than expected '%v'", o.Id, testValue) t.Errorf("APObject Id '%v' different than expected '%v'", o.Id, testValue) } if o.Type != OrganizationType { t.Errorf("Object Type '%v' different than expected '%v'", o.Type, OrganizationType) t.Errorf("APObject Type '%v' different than expected '%v'", o.Type, OrganizationType) } }
-
@@ -79,10 +79,10 @@ func TestServiceNew(t *testing.T) {o := ServiceNew(testValue) if o.Id != testValue { t.Errorf("Object Id '%v' different than expected '%v'", o.Id, testValue) t.Errorf("APObject Id '%v' different than expected '%v'", o.Id, testValue) } if o.Type != ServiceType { t.Errorf("Object Type '%v' different than expected '%v'", o.Type, ServiceType) t.Errorf("APObject Type '%v' different than expected '%v'", o.Type, ServiceType) } }
-
@@ -90,11 +90,11 @@ func TestValidActorType(t *testing.T) {var invalidType ActivityVocabularyType = "RandomType" if ValidActorType(invalidType) { t.Errorf("Object Type '%v' should not be valid", invalidType) t.Errorf("APObject Type '%v' should not be valid", invalidType) } for _, validType := range validActorTypes { if !ValidActorType(validType) { t.Errorf("Object Type '%v' should be valid", validType) t.Errorf("APObject Type '%v' should be valid", validType) } } }
-
-
-
@@ -5,7 +5,7 @@ var validCollectionTypes = [...]ActivityVocabularyType{CollectionType, OrderedCotype Page ObjectOrLink type Collection struct { *Object *APObject // A non-negative integer specifying the total number of objects contained by the logical view of the collection. // This number might not reflect the actual number of items serialized within the Collection object instance. TotalItems uint `jsonld:"totalItems,omitempty"`
-
@@ -14,7 +14,7 @@ type Collection struct {} type OrderedCollection struct { *Object *APObject // A non-negative integer specifying the total number of objects contained by the logical view of the collection. // This number might not reflect the actual number of items serialized within the Collection object instance. TotalItems uint `jsonld:"totalItems,omitempty"`
-
@@ -64,13 +64,13 @@ func ValidCollectionType(_type ActivityVocabularyType) bool {func CollectionNew(id ObjectId) *Collection { o := ObjectNew(id, CollectionType) return &Collection{Object: o} return &Collection{APObject: o} } func OrderedCollectionNew(id ObjectId) *OrderedCollection { o := ObjectNew(id, OrderedCollectionType) return &OrderedCollection{Object: o} return &OrderedCollection{APObject: o} } func CollectionPageNew(parent *Collection) *CollectionPage {
-
-
-
@@ -8,10 +8,10 @@ func TestCollectionNew(t *testing.T) {c := CollectionNew(testValue) if c.Id != testValue { t.Errorf("Object Id '%v' different than expected '%v'", c.Id, testValue) t.Errorf("APObject Id '%v' different than expected '%v'", c.Id, testValue) } if c.Type != CollectionType { t.Errorf("Object Type '%v' different than expected '%v'", c.Type, CollectionType) t.Errorf("APObject Type '%v' different than expected '%v'", c.Type, CollectionType) } }
-
@@ -21,10 +21,10 @@ func TestOrderedCollectionNew(t *testing.T) {c := OrderedCollectionNew(testValue) if c.Id != testValue { t.Errorf("Object Id '%v' different than expected '%v'", c.Id, testValue) t.Errorf("APObject Id '%v' different than expected '%v'", c.Id, testValue) } if c.Type != OrderedCollectionType { t.Errorf("Object Type '%v' different than expected '%v'", c.Type, OrderedCollectionType) t.Errorf("APObject Type '%v' different than expected '%v'", c.Type, OrderedCollectionType) } }
-
-
-
@@ -7,9 +7,10 @@ import (func TestCreateActivityNew(t *testing.T) { var testValue = ObjectId("test") var now time.Time c := CreateActivityNew(testValue, nil) now := time.Now() now = time.Now() if c.Activity.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", c.Activity.Id, testValue) }
-
-
-
@@ -6,19 +6,25 @@ var validLinkTypes = [...]ActivityVocabularyType{// A Link is an indirect, qualified reference to a resource identified by a URL. // The fundamental model for links is established by [ RFC5988]. // Many of the properties defined by the Activity Vocabulary allow values that are either instances of Object or Link. // Many of the properties defined by the Activity Vocabulary allow values that are either instances of APObject or Link. // When a Link is used, it establishes a qualified relation connecting the subject // (the containing object) to the resource identified by the href. // Properties of the Link are properties of the reference as opposed to properties of the resource. type Link struct { *BaseObject // Provides the globally unique identifier for an APObject or Link. Id ObjectId `jsonld:"id,omitempty"` // Identifies the APObject or Link type. Multiple values may be specified. Type ActivityVocabularyType `jsonld:"type,omitempty"` // A simple, human-readable, plain-text name for the object. // HTML markup MUST NOT be included. The name MAY be expressed using multiple language-tagged values. Name NaturalLanguageValue `jsonld:"name,omitempty,collapsible"` // A link relation associated with a Link. The value must conform to both the [HTML5] and // [RFC5988](https://tools.ietf.org/html/rfc5988) "link relation" definitions. // In the [HTML5], any string not containing the "space" U+0020, "tab" (U+0009), "LF" (U+000A), // "FF" (U+000C), "CR" (U+000D) or "," (U+002C) characters can be used as a valid link relation. Rel *Link `jsonld:"rel"` // When used on a Link, identifies the MIME media type of the referenced resource. // When used on an Object, identifies the MIME media type of the value of the content property. // When used on an APObject, identifies the MIME media type of the value of the content property. // If not specified, the content property is assumed to contain text/html content. MediaType MimeType `jsonld:"mediaType,omitempty"` // On a Link, specifies a hint as to the rendering height in device-independent pixels of the linked resource.
-
@@ -49,13 +55,11 @@ func LinkNew(id ObjectId, _type ActivityVocabularyType) *Link {if !ValidLinkType(_type) { _type = LinkType } p := BaseObject{Id: id, Type: _type} return &Link{BaseObject: &p} return &Link{Id: id, Type: _type} } func MentionNew(id ObjectId) *Mention { p := BaseObject{Id: id, Type: MentionType} return &Mention{BaseObject: &p} return &Mention{Id: id, Type: MentionType} } func (l *Link) IsLink() bool {
-
-
-
@@ -9,10 +9,10 @@ func TestLinkNew(t *testing.T) {l := LinkNew(testValue, testType) if l.Id != testValue { t.Errorf("Object Id '%v' different than expected '%v'", l.Id, testValue) t.Errorf("APObject Id '%v' different than expected '%v'", l.Id, testValue) } if l.Type != LinkType { t.Errorf("Object Type '%v' different than expected '%v'", l.Type, LinkType) t.Errorf("APObject Type '%v' different than expected '%v'", l.Type, LinkType) } }
-
-
-
@@ -9,7 +9,7 @@ type ObjectId stringconst ( ActivityBaseURI URI = URI("https://www.w3.org/ns/activitystreams#") ObjectType ActivityVocabularyType = "Object" ObjectType ActivityVocabularyType = "APObject" LinkType ActivityVocabularyType = "Link" ActivityType ActivityVocabularyType = "Activity" IntransitiveActivityType ActivityVocabularyType = "IntransitiveActivity"
-
@@ -17,7 +17,7 @@ const (CollectionType ActivityVocabularyType = "Collection" OrderedCollectionType ActivityVocabularyType = "OrderedCollection" // Object Types // APObject Types ArticleType ActivityVocabularyType = "Article" AudioType ActivityVocabularyType = "Audio" DocumentType ActivityVocabularyType = "Document"
-
@@ -79,11 +79,11 @@ type (NaturalLanguageValue map[LangRef]string ) func (o *Object) IsLink() bool { func (o *APObject) IsLink() bool { return ValidLinkType(o.Type) } func (o *Object) IsObject() bool { func (o *APObject) IsObject() bool { return ValidObjectType(o.Type) }
-
@@ -98,20 +98,16 @@ func (n NaturalLanguageValue) MarshalJSON() ([]byte, error) {} // Describes an object of any kind. // The Object type serves as the base type for most of the other kinds of objects defined in the Activity Vocabulary, // The APObject 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. type BaseObject struct { // Provides the globally unique identifier for an Object or Link. type APObject struct { // Provides the globally unique identifier for an APObject or Link. Id ObjectId `jsonld:"id,omitempty"` // Identifies the Object or Link type. Multiple values may be specified. // Identifies the APObject or Link type. Multiple values may be specified. Type ActivityVocabularyType `jsonld:"type,omitempty"` // A simple, human-readable, plain-text name for the object. // HTML markup MUST NOT be included. The name MAY be expressed using multiple language-tagged values. Name NaturalLanguageValue `jsonld:"name,omitempty,collapsible"` } type Object struct { *BaseObject // Identifies a resource attached or related to an object that potentially requires special handling. // The intent is to provide a model that is at least semantically similar to attachments in email. Attachment ObjectOrLink `jsonld:"attachment,omitempty"`
-
@@ -121,7 +117,7 @@ type Object struct {// Identifies one or more entities that represent the total population of entities // for which the object can considered to be relevant. Audience ObjectOrLink `jsonld:"audience,omitempty"` // The content or textual representation of the Object encoded as a JSON string. // The content or textual representation of the APObject encoded as a JSON string. // 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.)
-
@@ -161,7 +157,7 @@ type Object struct {// A natural language summarization of the object encoded as HTML. // *Multiple language tagged summaries may be provided.) Summary NaturalLanguageValue `jsonld:"summary,omitempty,collapsible"` // One or more "tags" that have been associated with an objects. A tag can be any kind of Object. // One or more "tags" that have been associated with an objects. A tag can be any kind of APObject. // The key difference between attachment and tag is that the former implies association by inclusion, // while the latter implies associated by reference. Tag ObjectOrLink `jsonld:"tag,omitempty"`
-
@@ -169,13 +165,13 @@ type Object struct {Updated time.Time `jsonld:"updated,omitempty"` // Identifies one or more links to representations of the object Url LinkOrUri `jsonld:"url,omitempty"` // Identifies an entity considered to be part of the public primary audience of an Object // Identifies an entity considered to be part of the public primary audience of an APObject To ObjectOrLink `jsonld:"to,omitempty"` // Identifies an Object that is part of the private primary audience of this Object. // Identifies an APObject that is part of the private primary audience of this APObject. Bto ObjectOrLink `jsonld:"bto,omitempty"` // Identifies an Object that is part of the public secondary audience of this Object. // Identifies an APObject that is part of the public secondary audience of this APObject. Cc ObjectOrLink `jsonld:"cc,omitempty"` // Identifies one or more Objects that are part of the private secondary audience of this Object. // Identifies one or more Objects that are part of the private secondary audience of this APObject. Bcc ObjectOrLink `jsonld:"bcc,omitempty"` // When the object describes a time-bound resource, such as an audio or video, a meeting, etc, // the duration property indicates the object's approximate duration.
-
@@ -209,14 +205,13 @@ func ValidObjectType(_type ActivityVocabularyType) bool {return ValidActivityType(_type) || ValidActorType(_type) || ValidCollectionType(_type) || ValidGenericType(_type) } func ObjectNew(id ObjectId, _type ActivityVocabularyType) *Object { func ObjectNew(id ObjectId, _type ActivityVocabularyType) *APObject { if !(ValidObjectType(_type)) { _type = ObjectType } p := BaseObject{Id: id, Type: _type} p.Name = make(NaturalLanguageValue, 0) o := Object{BaseObject: &p} o.Content = make(NaturalLanguageValue, 0) o.Summary = make(NaturalLanguageValue, 0) o := APObject{Id: id, Type: _type} o.Name = make(NaturalLanguageValue) o.Content = make(NaturalLanguageValue) o.Summary = make(NaturalLanguageValue) return &o }
-
-
-
@@ -11,18 +11,18 @@ func TestObjectNew(t *testing.T) {o := ObjectNew(testValue, testType) if o.Id != testValue { t.Errorf("Object Id '%v' different than expected '%v'", o.Id, testValue) t.Errorf("APObject Id '%v' different than expected '%v'", o.Id, testValue) } if o.Type != testType { t.Errorf("Object Type '%v' different than expected '%v'", o.Type, testType) t.Errorf("APObject Type '%v' different than expected '%v'", o.Type, testType) } n := ObjectNew(testValue, "") if n.Id != testValue { t.Errorf("Object Id '%v' different than expected '%v'", n.Id, testValue) t.Errorf("APObject Id '%v' different than expected '%v'", n.Id, testValue) } if n.Type != ObjectType { t.Errorf("Object Type '%v' different than expected '%v'", n.Type, ObjectType) t.Errorf("APObject Type '%v' different than expected '%v'", n.Type, ObjectType) } }
-
@@ -39,11 +39,11 @@ func TestValidObjectType(t *testing.T) {var invalidType ActivityVocabularyType = "RandomType" if ValidObjectType(invalidType) { t.Errorf("Object Type '%v' should not be valid", invalidType) t.Errorf("APObject Type '%v' should not be valid", invalidType) } for _, validType := range validObjectTypes { if !ValidObjectType(validType) { t.Errorf("Object Type '%v' should be valid", validType) t.Errorf("APObject Type '%v' should be valid", validType) } } }
-