Changes
13 changed files (+182/-182)
-
-
@@ -67,9 +67,9 @@ var validActivityTypes = [...]ActivityVocabularyType{// IntransitiveActivity Instances of IntransitiveActivity are a subtype of Activity representing intransitive actions. // The object property is therefore inappropriate for these activities. type IntransitiveActivity struct { apObject Object // 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. // Any single activity can have multiple actors. The actor may be specified using an indirect GetLink. Actor Actor `jsonld:"actor,omitempty"` // Describes the indirect object, or target, of the activity. // The precise meaning of the target is largely dependent on the type of action being described
-
@@ -89,7 +89,7 @@ type IntransitiveActivity struct {Source Source `jsonld:"source,omitempty"` } // Activity is a subtype of apObject that describes some form of action that may happen, // Activity is a subtype of GetObject 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
-
@@ -441,7 +441,7 @@ func ActivityNew(id ObjectID, _type ActivityVocabularyType, ob ObjectOrLink) *Ac_type = ActivityType } o := ObjectNew(id, _type) i := IntransitiveActivity{apObject: o} i := IntransitiveActivity{Object: o} a := Activity{IntransitiveActivity: &i} a.Object = ob
-
@@ -456,7 +456,7 @@ func IntransitiveActivityNew(id ObjectID, _type ActivityVocabularyType) *Intrans} o := ObjectNew(id, _type) return &IntransitiveActivity{apObject: o} return &IntransitiveActivity{Object: o} } func (a *Activity) RecipientsDeduplication() {
-
-
-
@@ -46,10 +46,10 @@ type Endpoints struct {// Actor is generally one of the ActivityStreams Actor Types, but they don't have to be. // For example, a Profile object might be used as an actor, or a type from an ActivityStreams extension. // Actors are retrieved like any other Object in ActivityPub. // Actors are retrieved like any other GetObject in ActivityPub. // Like other ActivityStreams objects, actors have an id, which is a URI. type Actor struct { apObject Object // A reference to an [ActivityStreams] OrderedCollection comprised of all the messages received by the actor; // see 5.2 Inbox. Inbox InboxStream `jsonld:"inbox,omitempty"`
-
@@ -111,7 +111,7 @@ func ActorNew(id ObjectID, _type ActivityVocabularyType) *Actor {_type = ActorType } o := ObjectNew(id, _type) a := Actor{apObject: o} a := Actor{Object: o} in := InboxNew()
-
@@ -156,42 +156,42 @@ func ServiceNew(id ObjectID) *Service {return &o } // IsLink validates if current Actor is a Link // IsLink validates if current Actor is a GetLink func (a Actor) IsLink() bool { return a.Type == LinkType || ValidLinkType(a.Type) } // IsObject validates if current Actor is an Object // IsObject validates if current Actor is an GetObject func (a Actor) IsObject() bool { return a.Type == ObjectType || ValidObjectType(a.Type) } // Object returns the apObject corresponding to the Actor object func (a Actor) Object() apObject { return a.apObject // GetObject returns the GetObject corresponding to the Actor object func (a Actor) GetObject() Object { return a.Object } // Link returns the Link corresponding to the Actor object // GetLink returns the GetLink corresponding to the Actor object func (a Actor) Link() Link { return Link{} } // IsLink validates if current Person is a Link // IsLink validates if current Person is a GetLink func (p Person) IsLink() bool { return p.Type == LinkType || ValidLinkType(p.Type) } // IsObject validates if current Person is an Object // IsObject validates if current Person is an GetObject func (p Person) IsObject() bool { return p.Type == ObjectType || ValidObjectType(p.Type) } // Object returns the apObject corresponding to the Person object func (p Person) Object() apObject { return p.apObject // GetObject returns the GetObject corresponding to the Person object func (p Person) GetObject() Object { return p.Object } // Link returns the Link corresponding to the Person object // GetLink returns the GetLink corresponding to the Person object func (p Person) Link() Link { return Link{} }
-
-
-
@@ -103,7 +103,7 @@ func TestValidActorType(t *testing.T) {func TestActor_IsLink(t *testing.T) { m := ActorNew("test", ActorType) if m.IsLink() { t.Errorf("%#v should not be a valid Link", m.Type) t.Errorf("%#v should not be a valid GetLink", m.Type) } }
-
@@ -116,22 +116,22 @@ func TestActor_IsObject(t *testing.T) {func TestActor_Object(t *testing.T) { m := ActorNew("test", ActorType) if reflect.DeepEqual(apObject{}, m.Object()) { t.Errorf("%#v should not be an empty activity pub object", m.Object()) if reflect.DeepEqual(Object{}, m.GetObject()) { t.Errorf("%#v should not be an empty activity pub object", m.GetObject()) } } func TestActor_Link(t *testing.T) { m := ActorNew("test", ActorType) if !reflect.DeepEqual(Link{}, m.Link()) { t.Errorf("%#v should be an empty Link object", m.Link()) t.Errorf("%#v should be an empty GetLink object", m.Link()) } } func TestPerson_IsLink(t *testing.T) { m := PersonNew("test") if m.IsLink() { t.Errorf("%#v should not be a valid Link", m.Type) t.Errorf("%#v should not be a valid GetLink", m.Type) } }
-
@@ -144,14 +144,14 @@ func TestPerson_IsObject(t *testing.T) {func TestPerson_Object(t *testing.T) { m := PersonNew("test") if reflect.DeepEqual(apObject{}, m.Object()) { t.Errorf("%#v should not be an empty activity pub object", m.Object()) if reflect.DeepEqual(Object{}, m.GetObject()) { t.Errorf("%#v should not be an empty activity pub object", m.GetObject()) } } func TestPerson_Link(t *testing.T) { m := PersonNew("test") if !reflect.DeepEqual(Link{}, m.Link()) { t.Errorf("%#v should be an empty Link object", m.Link()) t.Errorf("%#v should be an empty GetLink object", m.Link()) } }
-
-
-
@@ -9,9 +9,9 @@ type CollectionInterface interface {Append(o ObjectOrLink) error } // Collection is a subtype of Object that represents ordered or unordered sets of Object or Link instances. // Collection is a subtype of GetObject that represents ordered or unordered sets of GetObject or GetLink instances. type Collection struct { apObject Object // 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"`
-
@@ -22,7 +22,7 @@ type Collection struct {// OrderedCollection is a subtype of Collection in which members of the logical // collection are assumed to always be strictly ordered. type OrderedCollection struct { apObject Object // 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"`
-
@@ -81,14 +81,14 @@ func ValidCollectionType(_type ActivityVocabularyType) bool {func CollectionNew(id ObjectID) *Collection { o := ObjectNew(id, CollectionType) return &Collection{apObject: o} return &Collection{Object: o} } // CollectionNew initializes a new Collection func OrderedCollectionNew(id ObjectID) *OrderedCollection { o := ObjectNew(id, OrderedCollectionType) return &OrderedCollection{apObject: o} return &OrderedCollection{Object: o} } // CollectionNew initializes a new Collection
-
-
-
@@ -62,15 +62,15 @@ func TestValidCollectionType(t *testing.T) {func Test_OrderedCollection_Append(t *testing.T) { id := ObjectID("test") val := apObject{ID: ObjectID("grrr")} val := Object{ID: ObjectID("grrr")} c := OrderedCollectionNew(id) c.Append(val) if c.TotalItems != 1 { t.Errorf("Inbox collection of %q should have exactly an Object", c.Object().ID) t.Errorf("Inbox collection of %q should have exactly an GetObject", c.GetObject().ID) } if !reflect.DeepEqual(c.OrderedItems[0].Object(), val) { if !reflect.DeepEqual(c.OrderedItems[0].GetObject(), val) { t.Errorf("First item in Inbox is does not match %q", val.ID) } }
-
@@ -78,15 +78,15 @@ func Test_OrderedCollection_Append(t *testing.T) {func Test_Collection_Append(t *testing.T) { id := ObjectID("test") val := apObject{ID: ObjectID("grrr")} val := Object{ID: ObjectID("grrr")} c := CollectionNew(id) c.Append(val) if c.TotalItems != 1 { t.Errorf("Inbox collection of %q should have exactly an Object", c.Object().ID) t.Errorf("Inbox collection of %q should have exactly an GetObject", c.GetObject().ID) } if !reflect.DeepEqual(c.Items[0].Object(), val) { if !reflect.DeepEqual(c.Items[0].GetObject(), val) { t.Errorf("First item in Inbox is does not match %q", val.ID) } }
-
-
-
@@ -16,7 +16,7 @@ func CreateActivityNew(id ObjectID, a ObjectOrLink, o ObjectOrLink) CreateActiviok := false if a != nil { typ := a.Object().Type typ := a.GetObject().Type if typ == ApplicationType { var app Application app, ok = a.(Application)
-
-
-
@@ -39,31 +39,31 @@ func TestCreateActivityNewWithApplication(t *testing.T) {if now.Sub(c1.Published).Round(time.Millisecond) != 0 { t.Errorf("Published time '%v' different than expected '%v'", c1.Published, now) } if c1.Activity.Actor.Object().ID != a.ID { t.Errorf("Actor ID %q different than expected %q", c1.Activity.Actor.Object().ID, a.ID) if c1.Activity.Actor.GetObject().ID != a.ID { t.Errorf("Actor ID %q different than expected %q", c1.Activity.Actor.GetObject().ID, a.ID) } if !reflect.DeepEqual(c1.Activity.Actor.Object(), a.Object()) { t.Errorf("Actor %#v different than expected %#v", c1.Activity.Actor.Object(), a.Object()) if !reflect.DeepEqual(c1.Activity.Actor.GetObject(), a.GetObject()) { t.Errorf("Actor %#v different than expected %#v", c1.Activity.Actor.GetObject(), a.GetObject()) } /* if !reflect.DeepEqual(c1.Activity.Actor, Actor(*a)) { t.Errorf("Actor %#v\n\n different than expected\n\n %#v", c1.Activity.Actor, Actor(*a)) } */ if c1.Activity.Object.Object().ID != n.ID { t.Errorf("Object %q different than expected %q", c1.Activity.Object.Object().ID, n.ID) if c1.Activity.Object.GetObject().ID != n.ID { t.Errorf("GetObject %q different than expected %q", c1.Activity.Object.GetObject().ID, n.ID) } if !reflect.DeepEqual(c1.Activity.Object.Object(), n.Object()) { t.Errorf("Object %#v different than expected %#v", c1.Activity.Object.Object(), n.Object()) if !reflect.DeepEqual(c1.Activity.Object.GetObject(), n.GetObject()) { t.Errorf("GetObject %#v different than expected %#v", c1.Activity.Object.GetObject(), n.GetObject()) } if !reflect.DeepEqual(c1.Activity.Object, n) { t.Errorf("Object %#v different than expected %#v", c1.Activity.Object, n) t.Errorf("GetObject %#v different than expected %#v", c1.Activity.Object, n) } if c1.Activity.Actor.Inbox.TotalItems != 1 { t.Errorf("Inbox collection of %q should have exactly an Object", c1.Activity.Actor.Object().ID) t.Errorf("Inbox collection of %q should have exactly an GetObject", c1.Activity.Actor.GetObject().ID) } if !reflect.DeepEqual(c1.Activity.Actor.Inbox.OrderedItems[0].Object(), n.Object()) { t.Errorf("First item in Inbox is does not match %q", n.Object().ID) if !reflect.DeepEqual(c1.Activity.Actor.Inbox.OrderedItems[0].GetObject(), n.GetObject()) { t.Errorf("First item in Inbox is does not match %q", n.GetObject().ID) } }
-
@@ -83,25 +83,25 @@ func TestCreateActivityNewWithGroup(t *testing.T) {if now.Sub(c1.Published).Round(time.Millisecond) != 0 { t.Errorf("Published time '%v' different than expected '%v'", c1.Published, now) } if c1.Activity.Actor.Object().ID != g.ID { t.Errorf("Actor ID %q different than expected %q", c1.Activity.Actor.Object().ID, g.ID) if c1.Activity.Actor.GetObject().ID != g.ID { t.Errorf("Actor ID %q different than expected %q", c1.Activity.Actor.GetObject().ID, g.ID) } if !reflect.DeepEqual(c1.Activity.Actor.Object(), g.Object()) { t.Errorf("Actor %#v different than expected %#v", c1.Activity.Actor.Object(), g.Object()) if !reflect.DeepEqual(c1.Activity.Actor.GetObject(), g.GetObject()) { t.Errorf("Actor %#v different than expected %#v", c1.Activity.Actor.GetObject(), g.GetObject()) } /* if !reflect.DeepEqual(c1.Activity.Actor, Actor(*g)) { t.Errorf("Actor %#v\n\n different than expected\n\n %#v", c1.Activity.Actor, Actor(*g)) } */ if c1.Activity.Object.Object().ID != n.ID { t.Errorf("Object %q different than expected %q", c1.Activity.Object.Object().ID, n.ID) if c1.Activity.Object.GetObject().ID != n.ID { t.Errorf("GetObject %q different than expected %q", c1.Activity.Object.GetObject().ID, n.ID) } if !reflect.DeepEqual(c1.Activity.Object.Object(), n.Object()) { t.Errorf("Object %#v different than expected %#v", c1.Activity.Object.Object(), n.Object()) if !reflect.DeepEqual(c1.Activity.Object.GetObject(), n.GetObject()) { t.Errorf("GetObject %#v different than expected %#v", c1.Activity.Object.GetObject(), n.GetObject()) } if !reflect.DeepEqual(c1.Activity.Object, n) { t.Errorf("Object %#v different than expected %#v", c1.Activity.Object, n) t.Errorf("GetObject %#v different than expected %#v", c1.Activity.Object, n) } }
-
@@ -121,25 +121,25 @@ func TestCreateActivityNewWithOrganization(t *testing.T) {if now.Sub(c1.Published).Round(time.Millisecond) != 0 { t.Errorf("Published time '%v' different than expected '%v'", c1.Published, now) } if c1.Activity.Actor.Object().ID != o.ID { t.Errorf("Actor ID %q different than expected %q", c1.Activity.Actor.Object().ID, o.ID) if c1.Activity.Actor.GetObject().ID != o.ID { t.Errorf("Actor ID %q different than expected %q", c1.Activity.Actor.GetObject().ID, o.ID) } if !reflect.DeepEqual(c1.Activity.Actor.Object(), o.Object()) { t.Errorf("Actor %#v different than expected %#v", c1.Activity.Actor.Object(), o.Object()) if !reflect.DeepEqual(c1.Activity.Actor.GetObject(), o.GetObject()) { t.Errorf("Actor %#v different than expected %#v", c1.Activity.Actor.GetObject(), o.GetObject()) } /* if !reflect.DeepEqual(c1.Activity.Actor, Actor(*o)) { t.Errorf("Actor %#v\n\n different than expected\n\n %#v", c1.Activity.Actor, Actor(*o)) } */ if c1.Activity.Object.Object().ID != n.ID { t.Errorf("Object %q different than expected %q", c1.Activity.Object.Object().ID, n.ID) if c1.Activity.Object.GetObject().ID != n.ID { t.Errorf("GetObject %q different than expected %q", c1.Activity.Object.GetObject().ID, n.ID) } if !reflect.DeepEqual(c1.Activity.Object.Object(), n.Object()) { t.Errorf("Object %#v different than expected %#v", c1.Activity.Object.Object(), n.Object()) if !reflect.DeepEqual(c1.Activity.Object.GetObject(), n.GetObject()) { t.Errorf("GetObject %#v different than expected %#v", c1.Activity.Object.GetObject(), n.GetObject()) } if !reflect.DeepEqual(c1.Activity.Object, n) { t.Errorf("Object %#v different than expected %#v", c1.Activity.Object, n) t.Errorf("GetObject %#v different than expected %#v", c1.Activity.Object, n) } }
-
@@ -159,25 +159,25 @@ func TestCreateActivityNewWithPerson(t *testing.T) {if now.Sub(c1.Published).Round(time.Millisecond) != 0 { t.Errorf("Published time '%v' different than expected '%v'", c1.Published, now) } if c1.Activity.Actor.Object().ID != b.ID { t.Errorf("Actor ID %q different than expected %q", c1.Activity.Actor.Object().ID, b.ID) if c1.Activity.Actor.GetObject().ID != b.ID { t.Errorf("Actor ID %q different than expected %q", c1.Activity.Actor.GetObject().ID, b.ID) } if !reflect.DeepEqual(c1.Activity.Actor.Object(), b.Object()) { t.Errorf("Actor %#v different than expected %#v", c1.Activity.Actor.Object(), b.Object()) if !reflect.DeepEqual(c1.Activity.Actor.GetObject(), b.GetObject()) { t.Errorf("Actor %#v different than expected %#v", c1.Activity.Actor.GetObject(), b.GetObject()) } /* if !reflect.DeepEqual(c1.Activity.Actor, Actor(*b)) { t.Errorf("Actor %#v\n\n different than expected\n\n %#v", c1.Activity.Actor, Actor(*b)) } */ if c1.Activity.Object.Object().ID != n.ID { t.Errorf("Object %q different than expected %q", c1.Activity.Object.Object().ID, n.ID) if c1.Activity.Object.GetObject().ID != n.ID { t.Errorf("GetObject %q different than expected %q", c1.Activity.Object.GetObject().ID, n.ID) } if !reflect.DeepEqual(c1.Activity.Object.Object(), n.Object()) { t.Errorf("Object %#v different than expected %#v", c1.Activity.Object.Object(), n.Object()) if !reflect.DeepEqual(c1.Activity.Object.GetObject(), n.GetObject()) { t.Errorf("GetObject %#v different than expected %#v", c1.Activity.Object.GetObject(), n.GetObject()) } if !reflect.DeepEqual(c1.Activity.Object, n) { t.Errorf("Object %#v different than expected %#v", c1.Activity.Object, n) t.Errorf("GetObject %#v different than expected %#v", c1.Activity.Object, n) } }
-
@@ -197,25 +197,25 @@ func TestCreateActivityNewWithService(t *testing.T) {if now.Sub(c1.Published).Round(time.Millisecond) != 0 { t.Errorf("Published time '%v' different than expected '%v'", c1.Published, now) } if c1.Activity.Actor.Object().ID != s.ID { t.Errorf("Actor ID %q different than expected %q", c1.Activity.Actor.Object().ID, s.ID) if c1.Activity.Actor.GetObject().ID != s.ID { t.Errorf("Actor ID %q different than expected %q", c1.Activity.Actor.GetObject().ID, s.ID) } if !reflect.DeepEqual(c1.Activity.Actor.Object(), s.Object()) { t.Errorf("Actor %#v different than expected %#v", c1.Activity.Actor.Object(), s.Object()) if !reflect.DeepEqual(c1.Activity.Actor.GetObject(), s.GetObject()) { t.Errorf("Actor %#v different than expected %#v", c1.Activity.Actor.GetObject(), s.GetObject()) } /* if !reflect.DeepEqual(c1.Activity.Actor, Actor(*s)) { t.Errorf("Actor %#v\n\n different than expected\n\n %#v", c1.Activity.Actor, Actor(*s)) } */ if c1.Activity.Object.Object().ID != n.ID { t.Errorf("Object %q different than expected %q", c1.Activity.Object.Object().ID, n.ID) if c1.Activity.Object.GetObject().ID != n.ID { t.Errorf("GetObject %q different than expected %q", c1.Activity.Object.GetObject().ID, n.ID) } if !reflect.DeepEqual(c1.Activity.Object.Object(), n.Object()) { t.Errorf("Object %#v different than expected %#v", c1.Activity.Object.Object(), n.Object()) if !reflect.DeepEqual(c1.Activity.Object.GetObject(), n.GetObject()) { t.Errorf("GetObject %#v different than expected %#v", c1.Activity.Object.GetObject(), n.GetObject()) } if !reflect.DeepEqual(c1.Activity.Object, n) { t.Errorf("Object %#v different than expected %#v", c1.Activity.Object, n) t.Errorf("GetObject %#v different than expected %#v", c1.Activity.Object, n) } }
-
@@ -235,24 +235,24 @@ func TestCreateActivityNewWithActor(t *testing.T) {if now.Sub(c1.Published).Round(time.Millisecond) != 0 { t.Errorf("Published time '%v' different than expected '%v'", c1.Published, now) } if c1.Activity.Actor.Object().ID != a.ID { t.Errorf("Actor ID %q different than expected %q", c1.Activity.Actor.Object().ID, a.ID) if c1.Activity.Actor.GetObject().ID != a.ID { t.Errorf("Actor ID %q different than expected %q", c1.Activity.Actor.GetObject().ID, a.ID) } if !reflect.DeepEqual(c1.Activity.Actor.Object(), a.Object()) { t.Errorf("Actor %#v different than expected %#v", c1.Activity.Actor.Object(), a.Object()) if !reflect.DeepEqual(c1.Activity.Actor.GetObject(), a.GetObject()) { t.Errorf("Actor %#v different than expected %#v", c1.Activity.Actor.GetObject(), a.GetObject()) } /* if !reflect.DeepEqual(c1.Activity.Actor, *a) { t.Errorf("Actor %#v\n\n different than expected\n\n %#v", c1.Activity.Actor, *a) } */ if c1.Activity.Object.Object().ID != n.ID { t.Errorf("Object %q different than expected %q", c1.Activity.Object.Object().ID, n.ID) if c1.Activity.Object.GetObject().ID != n.ID { t.Errorf("GetObject %q different than expected %q", c1.Activity.Object.GetObject().ID, n.ID) } if !reflect.DeepEqual(c1.Activity.Object.Object(), n.Object()) { t.Errorf("Object %#v different than expected %#v", c1.Activity.Object.Object(), n.Object()) if !reflect.DeepEqual(c1.Activity.Object.GetObject(), n.GetObject()) { t.Errorf("GetObject %#v different than expected %#v", c1.Activity.Object.GetObject(), n.GetObject()) } if !reflect.DeepEqual(c1.Activity.Object, n) { t.Errorf("Object %#v different than expected %#v", c1.Activity.Object, n) t.Errorf("GetObject %#v different than expected %#v", c1.Activity.Object, n) } }
-
-
-
@@ -17,7 +17,7 @@ func InboxNew() *Inbox {id := ObjectID("inbox") o := ObjectNew(id, OrderedCollectionType) i := Inbox{apObject: o} i := Inbox{Object: o} i.TotalItems = 0 return &i
-
-
-
@@ -4,43 +4,43 @@ var validLinkTypes = [...]ActivityVocabularyType{MentionType, } // A Link is an indirect, qualified reference to a resource identified by a URL. // A GetLink 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 APObject or Link. // When a Link is used, it establishes a qualified relation connecting the subject // Many of the properties defined by the Activity Vocabulary allow values that are either instances of APObject or GetLink. // When a GetLink 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. // Properties of the GetLink are properties of the reference as opposed to properties of the resource. type Link struct { // Provides the globally unique identifier for an APObject or Link. // Provides the globally unique identifier for an APObject or GetLink. Id ObjectID `jsonld:"id,omitempty"` // Identifies the APObject or Link type. Multiple values may be specified. // Identifies the APObject or GetLink 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 // A link relation associated with a GetLink. 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 a GetLink, identifies the MIME media type of the referenced resource. // 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. // On a GetLink, specifies a hint as to the rendering height in device-independent pixels of the linked resource. Height uint `jsonld:"height,omitempty"` // On a Link, specifies a hint as to the rendering width in device-independent pixels of the linked resource. // On a GetLink, specifies a hint as to the rendering width in device-independent pixels of the linked resource. Width uint `jsonld:"width,omitempty"` // Identifies an entity that provides a preview of this object. Preview ObjectOrLink `jsonld:"preview,omitempty"` // The target resource pointed to by a Link. // The target resource pointed to by a GetLink. Href URI `jsonld:"href,omitempty"` // Hints as to the language used by the target resource. // Value must be a [BCP47](https://tools.ietf.org/html/bcp47) Language-Tag. HrefLang LangRef `jsonld:"hrefLang,omitempty"` } // Mention is a specialized Link that represents an @mention. // Mention is a specialized GetLink that represents an @mention. type Mention Link // ValidLinkType validates a type against the valid link types
-
@@ -53,7 +53,7 @@ func ValidLinkType(_type ActivityVocabularyType) bool {return false } // LinkNew initializes a new Link // LinkNew initializes a new GetLink func LinkNew(id ObjectID, _type ActivityVocabularyType) *Link { if !ValidLinkType(_type) { _type = LinkType
-
@@ -66,32 +66,32 @@ func MentionNew(id ObjectID) *Mention {return &Mention{Id: id, Type: MentionType} } // IsLink validates if current Link is a Link // IsLink validates if current GetLink is a GetLink func (l Link) IsLink() bool { return l.Type == LinkType || ValidLinkType(l.Type) } // IsObject validates if current Link is an Object // IsObject validates if current GetLink is an GetObject func (l Link) IsObject() bool { return l.Type == ObjectType || ValidObjectType(l.Type) } // IsLink validates if current Mention is a Link // IsLink validates if current Mention is a GetLink func (m Mention) IsLink() bool { return m.Type == MentionType || ValidLinkType(m.Type) } // IsObject validates if current Mention is an Object // IsObject validates if current Mention is an GetObject func (m Mention) IsObject() bool { return m.Type == ObjectType || ValidObjectType(m.Type) } // Object returns the apObject corresponding to the Mention object func (m Mention) Object() apObject { return apObject{} // GetObject returns the GetObject corresponding to the Mention object func (m Mention) GetObject() Object { return Object{} } // Link returns the Link corresponding to the Mention object func (m Mention) Link() Link { // GetLink returns the GetLink corresponding to the Mention object func (m Mention) GetLink() Link { return Link(m) }
-
-
-
@@ -23,14 +23,14 @@ func TestValidLinkType(t *testing.T) {var invalidType ActivityVocabularyType = "RandomType" if ValidLinkType(LinkType) { t.Errorf("Generic Link Type '%v' should not be valid", LinkType) t.Errorf("Generic GetLink Type '%v' should not be valid", LinkType) } if ValidLinkType(invalidType) { t.Errorf("Link Type '%v' should not be valid", invalidType) t.Errorf("GetLink Type '%v' should not be valid", invalidType) } for _, validType := range validLinkTypes { if !ValidLinkType(validType) { t.Errorf("Link Type '%v' should be valid", validType) t.Errorf("GetLink Type '%v' should be valid", validType) } } }
-
@@ -73,14 +73,14 @@ func TestMention_IsObject(t *testing.T) {func TestMention_Object(t *testing.T) { m := MentionNew("test") if !reflect.DeepEqual(apObject{}, m.Object()) { t.Errorf("%#v should be an empty object", m.Object()) if !reflect.DeepEqual(Object{}, m.GetObject()) { t.Errorf("%#v should be an empty object", m.GetObject()) } } func TestMention_Link(t *testing.T) { m := MentionNew("test") if !reflect.DeepEqual(Link(*m), m.Link()) { t.Errorf("%#v should be a Link object", m.Link()) if !reflect.DeepEqual(Link(*m), m.GetLink()) { t.Errorf("%#v should be a GetLink object", m.GetLink()) } }
-
-
-
@@ -24,14 +24,14 @@ const (// ActivityBaseURI the basic URI for the activity streams namespaces ActivityBaseURI URI = URI("https://www.w3.org/ns/activitystreams#") ObjectType ActivityVocabularyType = "ActivityPubObject" LinkType ActivityVocabularyType = "Link" LinkType ActivityVocabularyType = "GetLink" ActivityType ActivityVocabularyType = "Activity" IntransitiveActivityType ActivityVocabularyType = "IntransitiveActivity" ActorType ActivityVocabularyType = "Actor" CollectionType ActivityVocabularyType = "Collection" OrderedCollectionType ActivityVocabularyType = "OrderedCollection" // Activity Pub Object Types // Activity Pub GetObject Types ArticleType ActivityVocabularyType = "Article" AudioType ActivityVocabularyType = "Audio" DocumentType ActivityVocabularyType = "Document"
-
@@ -82,22 +82,22 @@ var validObjectTypes = [...]ActivityVocabularyType{type ( // ActivityVocabularyType is the data type for an Activity type object ActivityVocabularyType string // ActivityObject is a subtype of Object that describes some form of action that may happen, // ActivityObject is a subtype of GetObject that describes some form of action that may happen, // is currently happening, or has already happened ActivityObject interface{} // ObjectOrLink describes an object of any kind. ObjectOrLink interface { IsLink() bool IsObject() bool Object() apObject Link() Link GetObject() Object GetLink() Link } // ObjectsArr is a named type for matching an ObjectOrLink slice type to Collection interface ObjectsArr []ObjectOrLink // LinkOrURI is an interface that Object and Link structs implement, and at the same time // LinkOrURI is an interface that GetObject and GetLink structs implement, and at the same time // they are kept disjointed LinkOrURI interface{} // ImageOrLink is an interface that Image and Link structs implement // ImageOrLink is an interface that Image and GetLink structs implement ImageOrLink interface{} // MimeType is the type for MIME types MimeType string
-
@@ -107,13 +107,13 @@ type (NaturalLanguageValue map[LangRef]string ) // IsLink validates if current Activity Pub Object is a Link func (o apObject) IsLink() bool { // IsLink validates if current Activity Pub GetObject is a GetLink func (o Object) IsLink() bool { return ValidLinkType(o.Type) } // IsObject validates if current Activity Pub Object is an Object func (o apObject) IsObject() bool { // IsObject validates if current Activity Pub GetObject is an GetObject func (o Object) IsObject() bool { return ValidObjectType(o.Type) }
-
@@ -129,12 +129,12 @@ func (n NaturalLanguageValue) MarshalJSON() ([]byte, error) {} // 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, // The Activity Pub GetObject 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 apObject struct { // Provides the globally unique identifier for an Activity Pub Object or Link. type Object struct { // Provides the globally unique identifier for an Activity Pub GetObject or GetLink. ID ObjectID `jsonld:"id,omitempty"` // Identifies the Activity Pub Object or Link type. Multiple values may be specified. // Identifies the Activity Pub GetObject or GetLink 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.
-
@@ -148,7 +148,7 @@ type apObject 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 Activity Pub Object encoded as a JSON string. // The content or textual representation of the Activity Pub GetObject 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.)
-
@@ -188,7 +188,7 @@ type apObject 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 Activity Pub Object. // One or more "tags" that have been associated with an objects. A tag can be any kind of Activity Pub GetObject. // 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"`
-
@@ -196,13 +196,13 @@ type apObject 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 Activity Pub Object // Identifies an entity considered to be part of the public primary audience of an Activity Pub GetObject To ObjectsArr `jsonld:"to,omitempty"` // Identifies an Activity Pub Object that is part of the private primary audience of this Activity Pub Object. // Identifies an Activity Pub GetObject that is part of the private primary audience of this Activity Pub GetObject. Bto ObjectsArr `jsonld:"bto,omitempty"` // Identifies an Activity Pub Object that is part of the public secondary audience of this Activity Pub Object. // Identifies an Activity Pub GetObject that is part of the public secondary audience of this Activity Pub GetObject. CC ObjectsArr `jsonld:"cc,omitempty"` // Identifies one or more Objects that are part of the private secondary audience of this Activity Pub Object. // Identifies one or more Objects that are part of the private secondary audience of this Activity Pub GetObject. BCC ObjectsArr `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.
-
@@ -241,25 +241,25 @@ func ValidObjectType(_type ActivityVocabularyType) bool {return ValidActivityType(_type) || ValidActorType(_type) || ValidCollectionType(_type) || ValidGenericType(_type) } // ObjectNew initializes a new Object func ObjectNew(id ObjectID, _type ActivityVocabularyType) apObject { // ObjectNew initializes a new GetObject func ObjectNew(id ObjectID, _type ActivityVocabularyType) Object { if !(ValidObjectType(_type)) { _type = ObjectType } o := apObject{ID: id, Type: _type} o := Object{ID: id, Type: _type} o.Name = make(NaturalLanguageValue) o.Content = make(NaturalLanguageValue) o.Summary = make(NaturalLanguageValue) return o } // Object returns the apObject corresponding to the apObject object func (o apObject) Object() apObject { // GetObject returns the GetObject corresponding to the GetObject object func (o Object) GetObject() Object { return o } // Link returns the Link corresponding to the apObject object func (o apObject) Link() Link { // GetLink returns the GetLink corresponding to the GetObject object func (o Object) GetLink() Link { return Link{} }
-
@@ -289,14 +289,14 @@ func recipientsDeduplication(recArgs ...*ObjectsArr) error {for i, rec := range *recList { save := true for _, id := range recIds { if rec.Object().ID == id { if rec.GetObject().ID == id { // mark the element for removal toRemove = append(toRemove, i) save = false } } if save { recIds = append(recIds, rec.Object().ID) recIds = append(recIds, rec.GetObject().ID) } }
-
-
-
@@ -129,15 +129,15 @@ func TestObject_IsObject(t *testing.T) {func TestObject_Link(t *testing.T) { o := ObjectNew("test", ObjectType) if !reflect.DeepEqual(Link{}, o.Link()) { t.Errorf("%#v should be an empty Link object", o.Link()) if !reflect.DeepEqual(Link{}, o.GetLink()) { t.Errorf("%#v should be an empty GetLink object", o.GetLink()) } } func TestObjectsArr_Append(t *testing.T) { d := make(ObjectsArr, 0) val := apObject{ID: ObjectID("grrr")} val := Object{ID: ObjectID("grrr")} d.Append(val)
-
-
-
@@ -26,66 +26,66 @@ S2S Server: Activities requiring the object propertyadd := activitypub.AddNew("https://localhost/myactivity", obj, nil) if add.Object == nil { t.Errorf("Missing Object in Add activity %#v", add.Object) t.Errorf("Missing GetObject in Add activity %#v", add.Object) } if add.Object != obj { t.Errorf("Add.Object different than what we initialized %#v %#v", add.Object, obj) t.Errorf("Add.GetObject different than what we initialized %#v %#v", add.Object, obj) } block := activitypub.BlockNew("https://localhost/myactivity", obj) if block.Object == nil { t.Errorf("Missing Object in Add activity %#v", block.Object) t.Errorf("Missing GetObject in Add activity %#v", block.Object) } if block.Object != obj { t.Errorf("Block.Object different than what we initialized %#v %#v", block.Object, obj) t.Errorf("Block.GetObject different than what we initialized %#v %#v", block.Object, obj) } create := activitypub.CreateNew("https://localhost/myactivity", obj) if create.Object == nil { t.Errorf("Missing Object in Add activity %#v", create.Object) t.Errorf("Missing GetObject in Add activity %#v", create.Object) } if create.Object != obj { t.Errorf("Create.Object different than what we initialized %#v %#v", create.Object, obj) t.Errorf("Create.GetObject different than what we initialized %#v %#v", create.Object, obj) } delete := activitypub.DeleteNew("https://localhost/myactivity", obj) if delete.Object == nil { t.Errorf("Missing Object in Delete activity %#v", delete.Object) t.Errorf("Missing GetObject in Delete activity %#v", delete.Object) } if delete.Object != obj { t.Errorf("Delete.Object different than what we initialized %#v %#v", delete.Object, obj) t.Errorf("Delete.GetObject different than what we initialized %#v %#v", delete.Object, obj) } follow := activitypub.FollowNew("https://localhost/myactivity", obj) if follow.Object == nil { t.Errorf("Missing Object in Follow activity %#v", follow.Object) t.Errorf("Missing GetObject in Follow activity %#v", follow.Object) } if follow.Object != obj { t.Errorf("Follow.Object different than what we initialized %#v %#v", follow.Object, obj) t.Errorf("Follow.GetObject different than what we initialized %#v %#v", follow.Object, obj) } like := activitypub.LikeNew("https://localhost/myactivity", obj) if like.Object == nil { t.Errorf("Missing Object in Like activity %#v", like.Object) t.Errorf("Missing GetObject in Like activity %#v", like.Object) } if like.Object != obj { t.Errorf("Like.Object different than what we initialized %#v %#v", add.Object, obj) t.Errorf("Like.GetObject different than what we initialized %#v %#v", add.Object, obj) } update := activitypub.UpdateNew("https://localhost/myactivity", obj) if update.Object == nil { t.Errorf("Missing Object in Update activity %#v", update.Object) t.Errorf("Missing GetObject in Update activity %#v", update.Object) } if update.Object != obj { t.Errorf("Update.Object different than what we initialized %#v %#v", update.Object, obj) t.Errorf("Update.GetObject different than what we initialized %#v %#v", update.Object, obj) } undo := activitypub.UndoNew("https://localhost/myactivity", obj) if undo.Object == nil { t.Errorf("Missing Object in Undo activity %#v", undo.Object) t.Errorf("Missing GetObject in Undo activity %#v", undo.Object) } if undo.Object != obj { t.Errorf("Undo.Object different than what we initialized %#v %#v", undo.Object, obj) t.Errorf("Undo.GetObject different than what we initialized %#v %#v", undo.Object, obj) } }
-
@@ -155,11 +155,11 @@ S2S Server: Deduplication of recipient listcheckDedup := func(list activitypub.ObjectsArr, recIds *[]activitypub.ObjectID) error { for _, rec := range list { for _, id := range *recIds { if rec.Object().ID == id { if rec.GetObject().ID == id { return fmt.Errorf("%T[%s] already stored in recipients list, Deduplication faild", rec, id) } } *recIds = append(*recIds, rec.Object().ID) *recIds = append(*recIds, rec.GetObject().ID) } return nil }
-
@@ -216,8 +216,8 @@ Activity being notified aboutcheckActor := func(list activitypub.ObjectsArr, actor activitypub.Actor) error { for _, rec := range list { if rec.Object().ID == actor.Object().ID { return fmt.Errorf("%T[%s] Actor of activity should not be in the recipients list", rec, actor.Object().ID) if rec.GetObject().ID == actor.GetObject().ID { return fmt.Errorf("%T[%s] Actor of activity should not be in the recipients list", rec, actor.GetObject().ID) } } return nil
-
@@ -268,8 +268,8 @@ S2S Server: Do-not-deliver considerationscheckActor := func(list activitypub.ObjectsArr, ob activitypub.ObjectOrLink) error { for _, rec := range list { if rec.Object().ID == ob.Object().ID { return fmt.Errorf("%T[%s] of activity should not be in the recipients list", rec, ob.Object().ID) if rec.GetObject().ID == ob.GetObject().ID { return fmt.Errorf("%T[%s] of activity should not be in the recipients list", rec, ob.GetObject().ID) } } return nil
-