Activity Streams/Primer/Identifying Activity Objects

From W3C Wiki

There are four main ways of identifying if an AS2 object is an "Activity".

  1. By its location in the world. For example, ActivityPub inbox and outbox streams contain only Activity objects.
  2. Check its `type` agains a list of known activity types from the vocabulary spec.
  3. As a heuristic, it's possible to ducktype an Activity by looking for properties of an Activity like actor, object, target, result, origin, or instrument.
  4. Using inference on the Activity Streams 2.0 OWL vocabulary. This only works if the extension also provides an OWL vocabulary (?). It should be possible to determine that a given type is a direct or indirect sub-type of Activity.

Examples

By location

Consider this Activity object:

{
   "@context": "https://w3.org/ns/activitystreams",
   "type": "Person",
   "name": "The Chef",
   "outbox": {
      "type": "OrderedCollection",
      "items": [
        {
          "type": "Bake",
          "summary": "The Chef baked a chocolate cake.",
          "object": {
               "type": "Cake",
               "name": "Chocolate Cake"
          }
        }
      ]
   }
}

It represents a Person with an ActivityPub outbox property. Because the outbox contains Activity objects, we know that the first object in the items array is an Activity.

By type

Consider an extension vocabulary to Activity Streams for baking. Here's an Activity for baking a cake:

{
    "@context": [
        "https://w3.org/ns/activitystreams",
        {
            "kitchen": "https://kitchen.example/",
            "Bake": {
                "@id": "kitchen:Bake",
                "@type": "@id",
            },
            "Cake": {
                "@id": "kitchen:Cake",
                "@type": "@id",
            }
        }
    ],
    "type": ["Bake", "Create"],
    "actor": "https://kitchen.example/chef",
    "summary": "The Chef baked a chocolate cake.",
    "object": {
        "type": "Cake",
        "name": "Chocolate Cake"
    }
}

The producer of this activity has included multiple types. We can find "Create" in the list of Activity object types from the vocabulary doc, so we know it's an Activity object.

By property

Here's a similar example with a single type:

{
    "@context": [
        "https://w3.org/ns/activitystreams",
        {
            "kitchen": "https://kitchen.example/",
            "Bake": {
                "@id": "kitchen:Bake",
                "@type": "@id",
            },
            "Cake": {
                "@id": "kitchen:Cake",
                "@type": "@id",
            }
        }
    ],
    "type": "Bake",
    "actor": "https://kitchen.example/chef",
    "summary": "The Chef baked a chocolate cake.",
    "object": {
        "type": "Cake",
        "name": "Chocolate Cake"
    }
}

There's not (?) a way to specify that all objects with type "Bake" are also of type "Create".

The consumer can infer that this is an Activity because it has the "actor" and "object" properties.