Activitypub Server: Content negotiation inevitable?

When having e.g. an id of a post at hand (take https://pirati.ca/display/ec054ce7-1362-c9b5-3e7b-23f463322864), how would one go about to send a like?

It needs the inbox url - how to get that?

First send a GET to the id – which yields html (targeting the lesser tech savvy still preferring html over json).

How would one do that on a with static posts on a webserver like lighttpd, althttpd or thttpd?

You will need to send a json GET, obtain the attributedTo actor and then create a like with the ‘to’ field to that actor.

1 Like

thanks, that’s how I do but wanted ideas how to distinguish html and json connoisseurs.

I just found lighttpd can do such

  # https://stackoverflow.com/a/55632646
  $REQUEST_HEADER["Accept"] == "application/activity+json" {
    index-file.names = ( "index.json" )
  }

and return json to those who want it easily. Hope the other webservers may likewise.

We typically switch formats in the controller, but that doesn’t align with some architectures. Do whatever works.

Incidentally please do not trigger on ‘application/activity+json’ alone. ActivityPub uses ‘application/ld+json;profile=“\https://www.w3.org/ns/activitystreams”’ (without the backslash - which I needed to prevent a link preview) and using this is a MUST if I recall.

If you’re not supporting multiple protocols the ActivityPub definition is the gold standard.

We match on a few variations because new projects get it wrong about 50% of the time - and our own protocol is also based on ActivityStreams and that specification actually does use ‘application/activity+json’.

2 Likes

so maybe more appropriate may be

$REQUEST_HEADER["Accept"] =~ "[^/]+/.*json.*" {
    index-file.names = ( "index.json" )
}

If this works for your project - sure.