Skip to content

Instantly share code, notes, and snippets.

@wilkie
Created April 17, 2017 02:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilkie/bf0791aeb2f434e34c77530b0a196f66 to your computer and use it in GitHub Desktop.
Save wilkie/bf0791aeb2f434e34c77530b0a196f66 to your computer and use it in GitHub Desktop.

For uri-identifiers that are non-webfinger identifiers, you'll see people say @wilkie.fyi and this will mean it does discovery by looking at that page and discovering via content negotiation and/or links. This is useful for people who are creating content on sites that doesn't implement webfinger, for instance a blogging or photo posting site. They'll add Link tags instead and use a full URI. Basically: it is eas(ier) to syndicate that content without having to own the domain, but hard to add something to .well-known.

I might be @example.org/wilkie or even, dare I say, @mastodon.social/@wilkie but it will still look like @wilkie to humans. The same methods you are using to disambiguate, but hide the details to human beings, will still work here.

To disambiguate, in AS2, mentions and "hashtags" etc can be parsed universally using tag:

{
  "@context": "https://www.w3.org/ns/activitystreams",
  "name": "A thank-you note",
  "type": "Note",
  "content": "Thank you @sally for all your hard work! #givingthanks",
  "tag": [
    {
      "type": "Mention",
      "href": "http://example.org/people/sally",
      "name": "@sally"
    },
    {
      "id": "http://example.org/tags/givingthanks",
      "name": "#givingthanks"
    }
  ]
}

(https://www.w3.org/TR/activitystreams-vocabulary/#dfn-tag, https://www.w3.org/TR/activitystreams-vocabulary/#ex197-jsonld)

You'll notice in the example that @sally and #givingthanks are not encoded in html, but some nodes will send them wrapped in anchor tags. That is, content is always assumed encoded as HTML, and it is also valid if it says:

{
  ...
  "content": "Thank you <a href="http://example.org/people/sally">@sally</a> for all your hard work! <a href="http://example.org/tags/givingthanks">#givingthanks</a>"
  ...
}

In fact, you may need to infer the tag property by parsing the anchors since there is no strong (aka MUST) wording that they are to be used in AS2 or ActivityPub, and furthermore stronger targeting (using "to" to direct a message to somebody) makes tag redundant. (am I wrong??)

If you implement AS2 tags and mention types generally, you can support federation-opinions and identities that aren't webfinger enabled, or piece together a webfinger address (in the above, you can attempt acct:sally@example.org as a method of discovery... albeit after trying the href first)

Thus, based on seeing a "Mention" type, "to" etc, or "tag" discover the actor by following the href and reading:

  1. href as "application/activity+json" to look for an AS2 Actor, which gives you an ActivityPub "inbox", "outbox" etc (I should be able to content-negotiate https://mastodon.social/@wilkie and get the AP Actor)
  2. if that fails, read href as "text/html" and look for Links of type "application/activity+json" via rel "alternate" or "profile" (I should be able to see a on https://mastodon.social/@wilkie that points to the Actor
  3. if that fails, you might use the href's domain and name to form webfinger acct and get XRD/JRD in desperation (which might give you a "profile" rel, which you will start over with...)
  4. I might give up and parse the microformats / v-card at the href, following rel="me"/"profile" to get something to render to represent the Actor

Not very far away from what you'd do with normal webfinger addresses right now. Given a webfinger address to find an ActivityPub Actor you'd:

  1. template negotiation to get to XRD/JRD
  2. then, (with XRD's "profile") follow the steps above with the "profile" resource as your href.

It's not even a bad idea to still allow webfinger-style identifiers to map to ActivityPub/indie-web ones. If you want "@example.org/wilkie" to look like @wilkie@example.org, that should be fine. It'll look like:

{
  "@context": "https://www.w3.org/ns/activitystreams",
  "name": "A thank-you note",
  "type": "Note",
  "content": "Thank you @wilkie@example.org for your long replies to issues",
  "tag": [  {
      "type": "Mention",
      "href": "http://example.org/wilkie",
      "name": "@wilkie@example.org"
    }  ]
}

Because why not. Although, it should be noted that uri-based identifiers mean usernames may not be locally unique on a domain. Generally they are because it is a psychological user-expectation.

You could add an ActivtyStreams2/ActivityPub Actor to a JRD... but it isn't encouraged. (What is the recommendation?? I'm implying that you just add a uri as "profile" that leads to discovering the Actor via the above steps but it isn't spec'd)

Another note about the "content" field: If you strip html in your note content, you can rebuild the links from the tag attributes and even reformat them to a consistent style (some nodes may omit the @ symbol because they despise it for being inefficient or something... who knows... but you can add it back in) and add semantic information to them, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment