ActivityStreams

By default, EventBus uses ActivityStreams 1.0 as event format.
ActivityStreams 1.0 specification defineds several concepts and fields of a activity. For more details check their documentation.

Summary:
- It includes two parts here: Activity and Object.
- A event can be present as a Activity, And a Activity could include multiple Objects.

Conventions

EventName:

  • Use only lowercase letters, numbers, dots (.) and underscores (_);
  • Prefix names with a namespace followed by a dot (e.g. order., user.*);
  • End names with a verb that indicates what action it is (e.g. user.login, payment.subscribe).

Structure

Activity

Property Value Description Mandatory? PHP Type
id JSON [RFC4627] String Provides a permanent, universally unique identifier for the activity in the form of an absolute IRI [RFC3987]. An activity SHOULD contain a single id property. If an activity does not contain an id property, consumers MAY use the value of the url property as a less-reliable, non-unique identifier. y string
title JSON [RFC4627] String Natural-language title or headline for the activity encoded as a single JSON String containing HTML markup. An activity MAY contain a title property. y string
published [RFC3339] date-time The date and time at which the activity was published. An activity MUST contain a published property. y string
verb JSON [RFC4627] String Identifies the action that the activity describes. An activity SHOULD contain a verb property whose value is a JSON String that is non-empty and matches either the "isegment-nz-nc" or the "IRI" production in [RFC3339]. Note that the use of a relative reference other than a simple name is not allowed. If the verb is not specified, or if the value is null, the verb is assumed to be "post". y string
actor Object Describes the entity that performed the activity. An activity MUST contain one actor property whose value is a single Object. n ActivityObject
object Object Describes the primary object of the activity. For instance, in the activity, "John saved a movie to his wishlist", the object of the activity is "movie". An activity SHOULD contain an object property whose value is a single Object. If the object property is not contained, the primary object of the activity MAY be implied by context. n ActivityObject
target Object Describes the target of the activity. The precise meaning of the activity's target is dependent on the activities verb, but will often be the object the English preposition "to". For instance, in the activity, "John saved a movie to his wishlist", the target of the activity is "wishlist". The activity target MUST NOT be used to identity an indirect object that is not a target of the activity. An activity MAY contain a target property whose value is a single Object. n ActivityObject
provider Object Describes the application that published the activity. Note that this is not necessarily the same entity that generated the activity. An activity MAY contain a provider property whose value is a single Object. n ActivityObject
content JSON [RFC4627] String Natural-language description of the activity encoded as a single JSON String containing HTML markup. Visual elements such as thumbnail images MAY be included. An activity MAY contain a content property. n mixed
generator Object Describes the application that generated the activity. An activity MAY contain a generator property whose value is a single Object. n ActivityObject

Object

Property Value Description Mandatory? PHP Type
id JSON [RFC4627] String Provides a permanent, universally unique identifier for the object in the form of an absolute IRI [RFC3987]. An object SHOULD contain a single id property. If an object does not contain an id property, consumers MAY use the value of the url property as a less-reliable, non-unique identifier. n string
objectType JSON [RFC4627] String Identifies the type of object. An object MAY contain an objectType property whose value is a JSON String that is non-empty and matches either the "isegment-nz-nc" or the "IRI" production in [RFC3987]. Note that the use of a relative reference other than a simple name is not allowed. If no objectType property is contained, the object has no specific type. n string
attachments JSON [RFC4627] Array of Objects A collection of one or more additional, associated objects, similar to the concept of attached files in an email message. An object MAY have an attachments property whose value is a JSON Array of Objects. n ActivityObject[]
summary JSON [RFC4627] String Natural-language summarization of the object encoded as a single JSON String containing HTML markup. Visual elements such as thumbnail images MAY be included. An activity MAY contain a summary property. n mixed
content JSON [RFC4627] String Natural-language description of the object encoded as a single JSON String containing HTML markup. Visual elements such as thumbnail images MAY be included. An object MAY contain a content property. n mixed
downstreamDuplicates JSON [RFC4627] Array of Strings A JSON Array of one or more absolute IRI's [RFC3987] identifying objects that duplicate this object's content. An object SHOULD contain a downstreamDuplicates property when there are known objects, possibly in a different system, that duplicate the content in this object. This MAY be used as a hint for consumers to use when resolving duplicates between objects received from different sources. n string[]
upstreamDuplicates JSON [RFC4627] Array of Strings A JSON Array of one or more absolute IRI's [RFC3987] identifying objects that duplicate this object's content. An object SHOULD contain an upstreamDuplicates property when a publisher is knowingly duplicating with a new ID the content from another object. This MAY be used as a hint for consumers to use when resolving duplicates between objects received from different sources. n string[]
author Object Describes the entity that created or authored the object. An object MAY contain a single author property whose value is an Object of any type. Note that the author field identifies the entity that created the object and does not necessarily identify the entity that published the object. For instance, it may be the case that an object created by one person is posted and published to a system by an entirely different entity. n ActivityObject

User Cases (keep adding)

  • Case1: benn logged in

I will choose "user.login" as EventName, it following the conventions "namespace.verb"

title user.login
verb login
actor { objectType: "user", id: 123456 }
id Generated Unique String
published 2017-10-13T11:31:34+08:00
provider { objectType: "community", id: "Poppen" }
generator { id: "tnc-event-dispatcher", content: { mode: "async", class: "UserLoginEvent" } }
  • Case2: benn visited fan's profile
title user.visit
verb visit
actor { objectType: "user", id: 12345 }
object { objectType: "profile", id: "fan" }
id Generated Unique String
published 2017-10-13T11:31:34+08:00
provider { objectType: "community", id: "Poppen" }
generator { id: "tnc-event-dispatcher", content: { mode: "async", class: "UserLoginEvent" } }
  • Case3: benn send a message to leo
title message.send
verb send
actor { objectType: "user", id: 12345 }
object { objectType: "message", id: 112231 }
target { objectType: "user", id: 88929 }
id Generated Unique String
published 2017-10-13T11:31:34+08:00
provider { objectType: "community", id: "Poppen" }
generator { id: "tnc-event-dispatcher", content: { mode: "async", class: "UserLoginEvent" } }