What are your interoperability goals? Will the annotation servers only federate each other (at least, initially) or do you also want to federate with microblogging platforms like Mastodon? Federating the annotation data will be awkward, at best, with the microblogging platforms. You’d probably need to need transform the annotation objects into formatted AP Note objects of some kind.
How will you be processing the data? Will you be using plain JSON parsing and interpretation or using JSON-LD/RDF processing (both are options with JSON-LD representation)? I’m asking because there’s a minor issue with the terms in the Web Annotations and ActivityPub contexts overlapping ( target
, for example). JSON-LD processing would ensure the JSON keys are fully disambiguated. However, it may also be possible to hard-code which term is being used in a specific situation .
Those are some challenges, but there’s good news too. The Web Annotations context uses ActivityPub terms for some purposes. It looks like the collections and paging representations are using AP terms, for example.
A Create
activity might look like:
{
"@context": "https://www.w3.org/ns/activitystreams",
"type": "Create",
"id": "https://social.example/alyssa/activity/a29a6843-9feb-4c74-a7f7-081b9c9201d3",
"to": [
"https://chatty.example/ben/"
],
"actor": "https://social.example/alyssa/",
"object": {
"@context": "http://www.w3.org/ns/anno.jsonld",
"id": "http://server.example/anno-123",
"type": "Annotation",
"body": "http://server.example/my-annotation",
"target": "http://server.example/blog-article"
}
}
Some people will say you need to add Object
(will expand to “ActivityStreams 2.0 Terms”), in the annotation type
property, but it’s not required and doesn’t appear to serve any purpose in this case.
You can expose the annotation collections using the streams
property in the actor profile. However, there are also other options for exposing the collections along with some metadata.
Depending on how you manage the annotation collections, you may want to consider Add
and Remove
activities instead of Create
and Delete
.
When publishing, you could theoretically know which actors are using various AP implementations (via nodeinfo, which is supported by most platforms) and then format the outgoing activity to be compatible (for read-only notification interoperability). For Mastodon-like platforms, maybe the Annotation
would be converted to a Note
with the annotation body
as the content
with an embedded link to the target
. Currently, Mastodon would ignore an Annotation
-typed object.