Activity Streams/Primer/URLs as values
< Activity Streams | Primer
Example 11 of Activity Streams 2.0 core includes this JSON-LD:
{ "@context": "https://www.w3.org/ns/activitystreams", "type": "Application", "id": "http://example.org/application/123", "name": "Exampletron 3000", "image": "http://example.org/application/123.png" }
The image
property has a range of Image
or Link
. One question is whether the image property in the above example should be treated as:
- a
Link
with the URL "" - a
Link
with the id "" - an
Image
with the id ""
The document text clearly implies that it should be the first, but doesn't clarify why.
To maximize interoperability, consumers should treat any property that has a range of Object
and Link
and a value of a string as follows:
- Absent other information, assume that a bare string is the
href
of aLink
object, not anid
, which is possible but rarely used. - In ActivityPub, IDs can only be HTTPS URLs to an Activity Streams 2.0 document. So, one way to determine if the string is an ID or an Link URL, is to resolve the URL with an
Accept
header ofapplication/ld+json; profile="https://www.w3.org/ns/activitystreams"
orapplication/activity+json
, and if it is returned, the value is the ID of the returned object. This could also be cached; there may be other processing that suggests that the ID is an object ID. - In ActivityPub, if the ID is not an HTTPS URL to an AS2 object, assume that this is a
Link
withhref
property equal to the string. - In ActivityPub, absent other information, assume these properties are
Link
:attachment
,icon
,image
,preview
. - In ActivityPub, absent other information, assume all other properties that have a Range of
Link
orObject
areObject
. - In other uses of Activity Streams 2.0, there is no requirement for the structure of the
id
property. If the value is an URL that resolves to a resource of the type referenced, e.g. an image, it is reasonable to assume that this is aLink
. - As a last resort, checking the "extension" of the "file name" of the URL may give some suggestion of the publisher's intent.
Publishers should:
- Avoid including bare Object IDs where the domain is either Link or URL.
- Include the Link object for links instead of using the bare URL.