Changes
5 changed files (+120/-86)
-
-
@@ -100,7 +100,7 @@ type Activity struct {// For instance, in the activity "John added a movie to his wishlist", // the object of the activity is the movie added. // When used within a Relationship describes the entity to which the subject is related. Object ObjectOrLink `jsonld:"object,omitempty"` Object *ObjectOrLink `jsonld:"object,omitempty"` } type (
-
@@ -227,18 +227,18 @@ type Question struct {Closed bool `jsonld:"closed,omitempty"` } func AcceptNew(id ObjectId) *Accept { a := ActivityNew(id, AcceptType) func AcceptNew(id ObjectId, ob *ObjectOrLink) *Accept { a := ActivityNew(id, AcceptType, ob) o := Accept(*a) return &o } func AddNew(id ObjectId) *Add { a := ActivityNew(id, AddType) func AddNew(id ObjectId, ob *ObjectOrLink) *Add { a := ActivityNew(id, AddType, ob) o := Add(*a) return &o } func AnnounceNew(id ObjectId) *Announce { a := ActivityNew(id, AnnounceType) func AnnounceNew(id ObjectId, ob *ObjectOrLink) *Announce { a := ActivityNew(id, AnnounceType, ob) o := Announce(*a) return &o }
-
@@ -247,98 +247,98 @@ func ArriveNew(id ObjectId) *Arrive {o := Arrive(*a) return &o } func BlockNew(id ObjectId) *Block { a := ActivityNew(id, BlockType) func BlockNew(id ObjectId, ob *ObjectOrLink) *Block { a := ActivityNew(id, BlockType, ob) o := Block(*a) return &o } func CreateNew(id ObjectId) *Create { a := ActivityNew(id, CreateType) func CreateNew(id ObjectId, ob *ObjectOrLink) *Create { a := ActivityNew(id, CreateType, ob) o := Create(*a) return &o } func DeleteNew(id ObjectId) *Delete { a := ActivityNew(id, DeleteType) func DeleteNew(id ObjectId, ob *ObjectOrLink) *Delete { a := ActivityNew(id, DeleteType, ob) o := Delete(*a) return &o } func DislikeNew(id ObjectId) *Dislike { a := ActivityNew(id, DislikeType) func DislikeNew(id ObjectId, ob *ObjectOrLink) *Dislike { a := ActivityNew(id, DislikeType, ob) o := Dislike(*a) return &o } func FlagNew(id ObjectId) *Flag { a := ActivityNew(id, FlagType) func FlagNew(id ObjectId, ob *ObjectOrLink) *Flag { a := ActivityNew(id, FlagType, ob) o := Flag(*a) return &o } func FollowNew(id ObjectId) *Follow { a := ActivityNew(id, FollowType) func FollowNew(id ObjectId, ob *ObjectOrLink) *Follow { a := ActivityNew(id, FollowType, ob) o := Follow(*a) return &o } func IgnoreNew(id ObjectId) *Ignore { a := ActivityNew(id, IgnoreType) func IgnoreNew(id ObjectId, ob *ObjectOrLink) *Ignore { a := ActivityNew(id, IgnoreType, ob) o := Ignore(*a) return &o } func InviteNew(id ObjectId) *Invite { a := ActivityNew(id, InviteType) func InviteNew(id ObjectId, ob *ObjectOrLink) *Invite { a := ActivityNew(id, InviteType, ob) o := Invite(*a) return &o } func JoinNew(id ObjectId) *Join { a := ActivityNew(id, JoinType) func JoinNew(id ObjectId, ob *ObjectOrLink) *Join { a := ActivityNew(id, JoinType, ob) o := Join(*a) return &o } func LeaveNew(id ObjectId) *Leave { a := ActivityNew(id, LeaveType) func LeaveNew(id ObjectId, ob *ObjectOrLink) *Leave { a := ActivityNew(id, LeaveType, ob) o := Leave(*a) return &o } func LikeNew(id ObjectId) *Like { a := ActivityNew(id, LikeType) func LikeNew(id ObjectId, ob *ObjectOrLink) *Like { a := ActivityNew(id, LikeType, ob) o := Like(*a) return &o } func ListenNew(id ObjectId) *Listen { a := ActivityNew(id, ListenType) func ListenNew(id ObjectId, ob *ObjectOrLink) *Listen { a := ActivityNew(id, ListenType, ob) o := Listen(*a) return &o } func MoveNew(id ObjectId) *Move { a := ActivityNew(id, MoveType) func MoveNew(id ObjectId, ob *ObjectOrLink) *Move { a := ActivityNew(id, MoveType, ob) o := Move(*a) return &o } func OfferNew(id ObjectId) *Offer { a := ActivityNew(id, OfferType) func OfferNew(id ObjectId, ob *ObjectOrLink) *Offer { a := ActivityNew(id, OfferType, ob) o := Offer(*a) return &o } func RejectNew(id ObjectId) *Reject { a := ActivityNew(id, RejectType) func RejectNew(id ObjectId, ob *ObjectOrLink) *Reject { a := ActivityNew(id, RejectType, ob) o := Reject(*a) return &o } func ReadNew(id ObjectId) *Read { a := ActivityNew(id, ReadType) func ReadNew(id ObjectId, ob *ObjectOrLink) *Read { a := ActivityNew(id, ReadType, ob) o := Read(*a) return &o } func RemoveNew(id ObjectId) *Remove { a := ActivityNew(id, RemoveType) func RemoveNew(id ObjectId, ob *ObjectOrLink) *Remove { a := ActivityNew(id, RemoveType, ob) o := Remove(*a) return &o } func TentativeRejectNew(id ObjectId) *TentativeReject { a := ActivityNew(id, TentativeRejectType) func TentativeRejectNew(id ObjectId, ob *ObjectOrLink) *TentativeReject { a := ActivityNew(id, TentativeRejectType, ob) o := TentativeReject(*a) return &o } func TentativeAcceptNew(id ObjectId) *TentativeAccept { a := ActivityNew(id, TentativeAcceptType) func TentativeAcceptNew(id ObjectId, ob *ObjectOrLink) *TentativeAccept { a := ActivityNew(id, TentativeAcceptType, ob) o := TentativeAccept(*a) return &o }
-
@@ -347,18 +347,18 @@ func TravelNew(id ObjectId) *Travel {o := Travel(*a) return &o } func UndoNew(id ObjectId) *Undo { a := ActivityNew(id, UndoType) func UndoNew(id ObjectId, ob *ObjectOrLink) *Undo { a := ActivityNew(id, UndoType, ob) o := Undo(*a) return &o } func UpdateNew(id ObjectId) *Accept { a := ActivityNew(id, UpdateType) func UpdateNew(id ObjectId, ob *ObjectOrLink) *Accept { a := ActivityNew(id, UpdateType, ob) o := Accept(*a) return &o } func ViewNew(id ObjectId) *View { a := ActivityNew(id, ViewType) func ViewNew(id ObjectId, ob *ObjectOrLink) *View { a := ActivityNew(id, ViewType, ob) o := View(*a) return &o }
-
@@ -377,14 +377,17 @@ func ValidActivityType(_type ActivityVocabularyType) bool {return false } func ActivityNew(id ObjectId, _type ActivityVocabularyType) *Activity { func ActivityNew(id ObjectId, _type ActivityVocabularyType, ob *ObjectOrLink) *Activity { if !ValidActivityType(_type) { _type = ActivityType } o := ObjectNew(id, _type) a := IntransitiveActivity{Object: o} i := IntransitiveActivity{Object: o} return &Activity{IntransitiveActivity: &a} a := Activity{IntransitiveActivity: &i} a.Object = ob return &a } func IntransitiveActivityNew(id ObjectId, _type ActivityVocabularyType) *IntransitiveActivity {
-
-
-
@@ -6,7 +6,7 @@ func TestActivityNew(t *testing.T) {var testValue = ObjectId("test") var testType ActivityVocabularyType = "Accept" a := ActivityNew(testValue, testType) a := ActivityNew(testValue, testType, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) }
-
@@ -14,7 +14,7 @@ func TestActivityNew(t *testing.T) {t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, testType) } g := ActivityNew(testValue, "") g := ActivityNew(testValue, "", nil) if g.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", g.Id, testValue)
-
@@ -71,7 +71,7 @@ func TestValidActivityType(t *testing.T) {func TestAcceptNew(t *testing.T) { var testValue = ObjectId("test") a := AcceptNew(testValue) a := AcceptNew(testValue, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue)
-
@@ -84,7 +84,7 @@ func TestAcceptNew(t *testing.T) {func TestAddNew(t *testing.T) { var testValue = ObjectId("test") a := AddNew(testValue) a := AddNew(testValue, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue)
-
@@ -97,7 +97,7 @@ func TestAddNew(t *testing.T) {func TestAnnounceNew(t *testing.T) { var testValue = ObjectId("test") a := AnnounceNew(testValue) a := AnnounceNew(testValue, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue)
-
@@ -123,7 +123,7 @@ func TestArriveNew(t *testing.T) {func TestBlockNew(t *testing.T) { var testValue = ObjectId("test") a := BlockNew(testValue) a := BlockNew(testValue, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue)
-
@@ -136,7 +136,7 @@ func TestBlockNew(t *testing.T) {func TestCreateNew(t *testing.T) { var testValue = ObjectId("test") a := CreateNew(testValue) a := CreateNew(testValue, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue)
-
@@ -149,7 +149,7 @@ func TestCreateNew(t *testing.T) {func TestDeleteNew(t *testing.T) { var testValue = ObjectId("test") a := DeleteNew(testValue) a := DeleteNew(testValue, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue)
-
@@ -162,7 +162,7 @@ func TestDeleteNew(t *testing.T) {func TestDislikeNew(t *testing.T) { var testValue = ObjectId("test") a := DislikeNew(testValue) a := DislikeNew(testValue, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue)
-
@@ -175,7 +175,7 @@ func TestDislikeNew(t *testing.T) {func TestFlagNew(t *testing.T) { var testValue = ObjectId("test") a := FlagNew(testValue) a := FlagNew(testValue, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue)
-
@@ -188,7 +188,7 @@ func TestFlagNew(t *testing.T) {func TestFollowNew(t *testing.T) { var testValue = ObjectId("test") a := FollowNew(testValue) a := FollowNew(testValue, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue)
-
@@ -201,7 +201,7 @@ func TestFollowNew(t *testing.T) {func TestIgnoreNew(t *testing.T) { var testValue = ObjectId("test") a := IgnoreNew(testValue) a := IgnoreNew(testValue, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue)
-
@@ -214,7 +214,7 @@ func TestIgnoreNew(t *testing.T) {func TestInviteNew(t *testing.T) { var testValue = ObjectId("test") a := InviteNew(testValue) a := InviteNew(testValue, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue)
-
@@ -227,7 +227,7 @@ func TestInviteNew(t *testing.T) {func TestJoinNew(t *testing.T) { var testValue = ObjectId("test") a := JoinNew(testValue) a := JoinNew(testValue, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue)
-
@@ -240,7 +240,7 @@ func TestJoinNew(t *testing.T) {func TestLeaveNew(t *testing.T) { var testValue = ObjectId("test") a := LeaveNew(testValue) a := LeaveNew(testValue, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue)
-
@@ -253,7 +253,7 @@ func TestLeaveNew(t *testing.T) {func TestLikeNew(t *testing.T) { var testValue = ObjectId("test") a := LikeNew(testValue) a := LikeNew(testValue, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue)
-
@@ -266,7 +266,7 @@ func TestLikeNew(t *testing.T) {func TestListenNew(t *testing.T) { var testValue = ObjectId("test") a := ListenNew(testValue) a := ListenNew(testValue, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue)
-
@@ -279,7 +279,7 @@ func TestListenNew(t *testing.T) {func TestMoveNew(t *testing.T) { var testValue = ObjectId("test") a := MoveNew(testValue) a := MoveNew(testValue, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue)
-
@@ -292,7 +292,7 @@ func TestMoveNew(t *testing.T) {func TestOfferNew(t *testing.T) { var testValue = ObjectId("test") a := OfferNew(testValue) a := OfferNew(testValue, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue)
-
@@ -318,7 +318,7 @@ func TestQuestionNew(t *testing.T) {func TestRejectNew(t *testing.T) { var testValue = ObjectId("test") a := RejectNew(testValue) a := RejectNew(testValue, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue)
-
@@ -331,7 +331,7 @@ func TestRejectNew(t *testing.T) {func TestReadNew(t *testing.T) { var testValue = ObjectId("test") a := ReadNew(testValue) a := ReadNew(testValue, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue)
-
@@ -344,7 +344,7 @@ func TestReadNew(t *testing.T) {func TestRemoveNew(t *testing.T) { var testValue = ObjectId("test") a := RemoveNew(testValue) a := RemoveNew(testValue, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue)
-
@@ -357,7 +357,7 @@ func TestRemoveNew(t *testing.T) {func TestTentativeRejectNew(t *testing.T) { var testValue = ObjectId("test") a := TentativeRejectNew(testValue) a := TentativeRejectNew(testValue, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue)
-
@@ -370,7 +370,7 @@ func TestTentativeRejectNew(t *testing.T) {func TestTentativeAcceptNew(t *testing.T) { var testValue = ObjectId("test") a := TentativeAcceptNew(testValue) a := TentativeAcceptNew(testValue, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue)
-
@@ -396,7 +396,7 @@ func TestTravelNew(t *testing.T) {func TestUndoNew(t *testing.T) { var testValue = ObjectId("test") a := UndoNew(testValue) a := UndoNew(testValue, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue)
-
@@ -409,7 +409,7 @@ func TestUndoNew(t *testing.T) {func TestUpdateNew(t *testing.T) { var testValue = ObjectId("test") a := UpdateNew(testValue) a := UpdateNew(testValue, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue)
-
@@ -422,7 +422,7 @@ func TestUpdateNew(t *testing.T) {func TestViewNew(t *testing.T) { var testValue = ObjectId("test") a := ViewNew(testValue) a := ViewNew(testValue, nil) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue)
-
-
-
@@ -3,8 +3,17 @@ package activitypubimport "time" type CreateActivity struct { Activity Create Activity *Create Published time.Time To Actor CC Actor To *Actor CC *Actor } func CreateActivityNew(id ObjectId, o *ObjectOrLink) *CreateActivity { c := CreateActivity{ Activity: CreateNew(id, o), Published: time.Now(), } return &c }
-
-
-
@@ -0,0 +1,22 @@package activitypub import ( "testing" "time" ) func TestCreateActivityNew(t *testing.T) { var testValue = ObjectId("test") c := CreateActivityNew(testValue, nil) now := time.Now() if c.Activity.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", c.Activity.Id, testValue) } if c.Activity.Type != CreateType { t.Errorf("Activity Type '%v' different than expected '%v'", c.Activity.Type, CreateType) } if now.Sub(c.Published).Round(time.Millisecond) != 0 { t.Errorf("Published time '%v' different than expected '%v'", c.Published, now) } }
-
-
-
@@ -9,7 +9,7 @@ import () func TestAcceptSerialization(t *testing.T) { obj := activitypub.AcceptNew("https://localhost/myactivity") obj := activitypub.AcceptNew("https://localhost/myactivity", nil) obj.Name = make(activitypub.NaturalLanguageValue, 1) obj.Name["en"] = "test"
-
@@ -35,7 +35,7 @@ func TestAcceptSerialization(t *testing.T) {func TestCreateActivityHTTPSerialization(t *testing.T) { id := activitypub.ObjectId("test_object") obj := activitypub.AcceptNew(id) obj := activitypub.AcceptNew(id, nil) obj.Name["en"] = "Accept New" baseUri := string(activitypub.ActivityBaseURI)
-