Changes
2 changed files (+629/-0)
-
-
@@ -78,6 +78,129 @@ type Activity struct {Object ObjectOrLink `jsonld:"object,omitempty"` } // Indicates that the actor accepts the object. The target property can be used in certain circumstances to indicate // the context into which the object has been accepted. type Accept Activity // Indicates that the actor has added the object to the target. If the target property is not explicitly specified, // the target would need to be determined implicitly by context. // The origin can be used to identify the context from which the object originated. type Add Activity // Indicates that the actor is calling the target's attention the object. // The origin typically has no defined meaning. type Announce Activity // An IntransitiveActivity that indicates that the actor has arrived at the location. // The origin can be used to identify the context from which the actor originated. // The target typically has no defined meaning. type Arrive IntransitiveActivity // Indicates that the actor is blocking the object. Blocking is a stronger form of Ignore. // The typical use is to support social systems that allow one user to block activities or content of other users. // The target and origin typically have no defined meaning. type Block Ignore // Indicates that the actor has created the object. type Create Activity // Indicates that the actor has deleted the object. // If specified, the origin indicates the context from which the object was deleted. type Delete Activity // Indicates that the actor dislikes the object. type Dislike Activity // Indicates that the actor is "flagging" the object. // Flagging is defined in the sense common to many social platforms as reporting content as being // inappropriate for any number of reasons. type Flag Activity // Indicates that the actor is "following" the object. Following is defined in the sense typically used within // Social systems in which the actor is interested in any activity performed by or on the object. // The target and origin typically have no defined meaning. type Follow Activity // Indicates that the actor is ignoring the object. The target and origin typically have no defined meaning. type Ignore Activity // A specialization of Offer in which the actor is extending an invitation for the object to the target. type Invite Offer // Indicates that the actor has joined the object. The target and origin typically have no defined meaning. type Join Activity // Indicates that the actor has left the object. The target and origin typically have no meaning. type Leave Activity // Indicates that the actor likes, recommends or endorses the object. // The target and origin typically have no defined meaning. type Like Activity // Inherits all properties from Activity. type Listen Activity // Indicates that the actor has moved object from origin to target. // If the origin or target are not specified, either can be determined by context. type Move Activity // Indicates that the actor is offering the object. // If specified, the target indicates the entity to which the object is being offered. type Offer Activity // Indicates that the actor is rejecting the object. The target and origin typically have no defined meaning. type Reject Activity // Indicates that the actor has read the object. type Read Activity // Indicates that the actor is removing the object. If specified, // the origin indicates the context from which the object is being removed. type Remove Activity // A specialization of Reject in which the rejection is considered tentative. type TentativeReject Reject // A specialization of Accept indicating that the acceptance is tentative. // A specialization of Accept indicating that the acceptance is tentative. type TentativeAccept Accept // Indicates that the actor is traveling to target from origin. // Travel is an IntransitiveObject whose actor specifies the direct object. // If the target or origin are not specified, either can be determined by context. type Travel IntransitiveActivity // Indicates that the actor is undoing the object. In most cases, the object will be an Activity describing // some previously performed action (for instance, a person may have previously "liked" an article but, // for whatever reason, might choose to undo that like at some later point in time). // The target and origin typically have no defined meaning. type Undo Activity // Indicates that the actor has updated the object. Note, however, that this vocabulary does not define a mechanism // for describing the actual set of modifications made to object. // The target and origin typically have no defined meaning. type Update Activity // Indicates that the actor has viewed the object. type View Activity // Represents a question being asked. Question objects are an extension of IntransitiveActivity. // That is, the Question object is an Activity, but the direct object is the question // itself and therefore it would not contain an object property. // Either of the anyOf and oneOf properties may be used to express possible answers, // but a Question object must not have both properties. type Question struct { *IntransitiveActivity // Identifies an exclusive option for a Question. Use of oneOf implies that the Question // can have only a single answer. To indicate that a Question can have multiple answers, use anyOf. OneOf ObjectOrLink `jsonld:"oneOf,omitempty"` // Identifies an inclusive option for a Question. Use of anyOf implies that the Question can have multiple answers. // To indicate that a Question can have only one answer, use oneOf. AnyOf ObjectOrLink `jsonld:"anyOf,omitempty"` // Indicates that a question has been closed, and answers are no longer accepted. Closed bool `jsonld:"closed,omitempty"` } // Instances of IntransitiveActivity are a subtype of Activity representing intransitive actions. // The object property is therefore inappropriate for these activities. type IntransitiveActivity struct {
-
@@ -103,6 +226,147 @@ type IntransitiveActivity struct {Source Source } func AcceptNew(id ObjectId) *Accept { a := ActivityNew(id, AcceptType) o := Accept(*a) return &o } func AddNew(id ObjectId) *Add { a := ActivityNew(id, AddType) o := Add(*a) return &o } func AnnounceNew(id ObjectId) *Announce { a := ActivityNew(id, AnnounceType) o := Announce(*a) return &o } func ArriveNew(id ObjectId) *Arrive { a := IntransitiveActivityNew(id, ArriveType) o := Arrive(*a) return &o } func BlockNew(id ObjectId) *Block { a := ActivityNew(id, BlockType) o := Block(*a) return &o } func CreateNew(id ObjectId) *Create { a := ActivityNew(id, CreateType) o := Create(*a) return &o } func DeleteNew(id ObjectId) *Delete { a := ActivityNew(id, DeleteType) o := Delete(*a) return &o } func DislikeNew(id ObjectId) *Dislike { a := ActivityNew(id, DislikeType) o := Dislike(*a) return &o } func FlagNew(id ObjectId) *Flag { a := ActivityNew(id, FlagType) o := Flag(*a) return &o } func FollowNew(id ObjectId) *Follow { a := ActivityNew(id, FollowType) o := Follow(*a) return &o } func IgnoreNew(id ObjectId) *Ignore { a := ActivityNew(id, IgnoreType) o := Ignore(*a) return &o } func InviteNew(id ObjectId) *Invite { a := ActivityNew(id, InviteType) o := Invite(*a) return &o } func JoinNew(id ObjectId) *Join { a := ActivityNew(id, JoinType) o := Join(*a) return &o } func LeaveNew(id ObjectId) *Leave { a := ActivityNew(id, LeaveType) o := Leave(*a) return &o } func LikeNew(id ObjectId) *Like { a := ActivityNew(id, LikeType) o := Like(*a) return &o } func ListenNew(id ObjectId) *Listen { a := ActivityNew(id, ListenType) o := Listen(*a) return &o } func MoveNew(id ObjectId) *Move { a := ActivityNew(id, MoveType) o := Move(*a) return &o } func OfferNew(id ObjectId) *Offer { a := ActivityNew(id, OfferType) o := Offer(*a) return &o } func RejectNew(id ObjectId) *Reject { a := ActivityNew(id, RejectType) o := Reject(*a) return &o } func ReadNew(id ObjectId) *Read { a := ActivityNew(id, ReadType) o := Read(*a) return &o } func RemoveNew(id ObjectId) *Remove { a := ActivityNew(id, RemoveType) o := Remove(*a) return &o } func TentativeRejectNew(id ObjectId) *TentativeReject { a := ActivityNew(id, TentativeRejectType) o := TentativeReject(*a) return &o } func TentativeAcceptNew(id ObjectId) *TentativeAccept { a := ActivityNew(id, TentativeAcceptType) o := TentativeAccept(*a) return &o } func TravelNew(id ObjectId) *Travel { a := IntransitiveActivityNew(id, TravelType) o := Travel(*a) return &o } func UndoNew(id ObjectId) *Undo { a := ActivityNew(id, UndoType) o := Undo(*a) return &o } func UpdateNew(id ObjectId) *Accept { a := ActivityNew(id, UpdateType) o := Accept(*a) return &o } func ViewNew(id ObjectId) *View { a := ActivityNew(id, ViewType) o := View(*a) return &o } func QuestionNew(id ObjectId) *Question { a := IntransitiveActivityNew(id, QuestionType) o := Question{IntransitiveActivity: a} return &o } func ValidActivityType(_type string) bool { for _, v := range validActivityTypes { if v == _type {
-
-
-
@@ -62,4 +62,369 @@ func TestValidActivityType(t *testing.T) {t.Errorf("Activity Type '%v' should be valid", validType) } } } func TestAcceptNew(t *testing.T) { var testValue = ObjectId("test") a := AcceptNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != AcceptType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, AcceptType) } } func TestAddNew(t *testing.T) { var testValue = ObjectId("test") a := AddNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != AddType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, AddType) } } func TestAnnounceNew(t *testing.T) { var testValue = ObjectId("test") a := AnnounceNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != AnnounceType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, AnnounceType) } } func TestArriveNew(t *testing.T) { var testValue = ObjectId("test") a := ArriveNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != ArriveType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, ArriveType) } } func TestBlockNew(t *testing.T) { var testValue = ObjectId("test") a := BlockNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != BlockType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, BlockType) } } func TestCreateNew(t *testing.T) { var testValue = ObjectId("test") a := CreateNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != CreateType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, CreateType) } } func TestDeleteNew(t *testing.T) { var testValue = ObjectId("test") a := DeleteNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != DeleteType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, DeleteType) } } func TestDislikeNew(t *testing.T) { var testValue = ObjectId("test") a := DislikeNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != DislikeType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, DislikeType) } } func TestFlagNew(t *testing.T) { var testValue = ObjectId("test") a := FlagNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != FlagType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, FlagType) } } func TestFollowNew(t *testing.T) { var testValue = ObjectId("test") a := FollowNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != FollowType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, FollowType) } } func TestIgnoreNew(t *testing.T) { var testValue = ObjectId("test") a := IgnoreNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != IgnoreType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, IgnoreType) } } func TestInviteNew(t *testing.T) { var testValue = ObjectId("test") a := InviteNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != InviteType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, InviteType) } } func TestJoinNew(t *testing.T) { var testValue = ObjectId("test") a := JoinNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != JoinType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, JoinType) } } func TestLeaveNew(t *testing.T) { var testValue = ObjectId("test") a := LeaveNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != LeaveType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, LeaveType) } } func TestLikeNew(t *testing.T) { var testValue = ObjectId("test") a := LikeNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != LikeType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, LikeType) } } func TestListenNew(t *testing.T) { var testValue = ObjectId("test") a := ListenNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != ListenType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, ListenType) } } func TestMoveNew(t *testing.T) { var testValue = ObjectId("test") a := MoveNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != MoveType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, MoveType) } } func TestOfferNew(t *testing.T) { var testValue = ObjectId("test") a := OfferNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != OfferType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, OfferType) } } func TestQuestionNew(t *testing.T) { var testValue = ObjectId("test") a := QuestionNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != QuestionType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, QuestionType) } } func TestRejectNew(t *testing.T) { var testValue = ObjectId("test") a := RejectNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != RejectType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, RejectType) } } func TestReadNew(t *testing.T) { var testValue = ObjectId("test") a := ReadNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != ReadType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, ReadType) } } func TestRemoveNew(t *testing.T) { var testValue = ObjectId("test") a := RemoveNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != RemoveType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, RemoveType) } } func TestTentativeRejectNew(t *testing.T) { var testValue = ObjectId("test") a := TentativeRejectNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != TentativeRejectType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, TentativeRejectType) } } func TestTentativeAcceptNew(t *testing.T) { var testValue = ObjectId("test") a := TentativeAcceptNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != TentativeAcceptType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, TentativeAcceptType) } } func TestTravelNew(t *testing.T) { var testValue = ObjectId("test") a := TravelNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != TravelType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, TravelType) } } func TestUndoNew(t *testing.T) { var testValue = ObjectId("test") a := UndoNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != UndoType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, UndoType) } } func TestUpdateNew(t *testing.T) { var testValue = ObjectId("test") a := UpdateNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != UpdateType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, UpdateType) } } func TestViewNew(t *testing.T) { var testValue = ObjectId("test") a := ViewNew(testValue) if a.Id != testValue { t.Errorf("Activity Id '%v' different than expected '%v'", a.Id, testValue) } if a.Type != ViewType { t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, ViewType) } }
-