Changes
6 changed files (+97/-13)
-
-
@@ -70,7 +70,7 @@ type IntransitiveActivity struct {*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"` Actor ObjectOrLink `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 // but will often be the object of the English preposition "to".
-
-
-
@@ -148,3 +148,43 @@ func ServiceNew(id ObjectID) *Service {o := Service(*a) return &o } // IsLink validates if current Actor is a Link func (a Actor) IsLink() bool { return a.Type == LinkType || ValidLinkType(a.Type) } // IsObject validates if current Actor is an Object 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) } // Link returns the Link corresponding to the Actor object func (a Actor) Link() Link { return Link{} } // IsLink validates if current Person is a Link func (p Person) IsLink() bool { return p.Type == LinkType || ValidLinkType(p.Type) } // IsObject validates if current Person is an Object 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 } // Link returns the Link corresponding to the Person object func (p Person) Link() Link { return p.Link() }
-
-
-
@@ -2,20 +2,42 @@ package activitypubimport "time" //import "fmt" // CreateActivity is the type for a create activity message type CreateActivity struct { Activity *Create Published time.Time To *Actor CC *Actor To *ObjectOrLink CC *ObjectOrLink } // CreateActivityNew initializes a new CreateActivity message func CreateActivityNew(id ObjectID, a ObjectOrLink, o ObjectOrLink) *CreateActivity { act := CreateNew(id, o) ok := false if a != nil { act.Actor = Actor(a.(Person)) typ := a.Object().Type if typ == ApplicationType { act.Actor, ok = a.(Application) } if typ == GroupType { act.Actor, ok = a.(Group) } if typ == OrganizationType { act.Actor, ok = a.(Organization) } if typ == PersonType { act.Actor, ok = a.(Person) } if typ == ServiceType { act.Actor, ok = a.(Service) } //fmt.Printf("type %v\nok is %t", act.Actor.Object(), ok) if !ok { act.Actor, ok = a.(Actor) } } c := CreateActivity{
-
-
-
@@ -26,7 +26,7 @@ func TestCreateActivityNew(t *testing.T) {n := ObjectNew("my:note", NoteType) b := PersonNew("bob") c1 := CreateActivityNew(testValue, *b, n) c1 := CreateActivityNew(testValue, b, n) now = time.Now() if c1.Activity.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", c1.Activity.Id, testValue)
-
@@ -37,10 +37,12 @@ func TestCreateActivityNew(t *testing.T) {if now.Sub(c.Published).Round(time.Millisecond) != 0 { t.Errorf("Published time '%v' different than expected '%v'", c1.Published, now) } if !reflect.DeepEqual(c1.Activity.Actor, Actor(*b)) { t.Errorf("Actor \n'%#v' different than expected \n'%#v'", c1.Activity.Actor, b) } /* if !reflect.DeepEqual(c1.Activity.Actor.Object().Name, b.Object().Name) { t.Errorf("Actor \n'%#v'\n\n different than expected \n\n'%#v'", c1.Activity.Actor.Object().Name, b.Object().Name) } */ if !reflect.DeepEqual(c1.Activity.Object.(*apObject), n) { t.Errorf("Object \n'%#v' different than expected \n'%#v'", c1.Activity.Object, n) t.Errorf("Object \n'%#v'\n\n different than expected \n\n'%#v'\n", c1.Activity.Object, n) } }
-
-
-
@@ -77,11 +77,21 @@ func (l Link) IsObject() bool {} // IsLink validates if current Mention is a Link func (l Mention) IsLink() bool { return l.Type == MentionType || ValidLinkType(l.Type) func (m Mention) IsLink() bool { return m.Type == MentionType || ValidLinkType(m.Type) } // IsObject validates if current Mention is an Object func (l Mention) IsObject() bool { return l.Type == ObjectType || ValidObjectType(l.Type) 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{} } // Link returns the Link corresponding to the Mention object func (m Mention) Link() Link { return Link(m) }
-
-
-
@@ -249,3 +249,13 @@ func ObjectNew(id ObjectID, _type ActivityVocabularyType) *apObject {o.Summary = make(NaturalLanguageValue) return &o } // Object returns the apObject corresponding to the apObject object func (o apObject) Object() apObject { return o } // Link returns the Link corresponding to the apObject object func (o apObject) Link() Link { return Link{} }
-