benbrown / shuttlecraft

a single user activitypub server - join the federation!
https://shuttlecraft.net
MIT License
264 stars 30 forks source link

Request to get list of replies to a post returns error #98

Open patrickmcurry opened 1 year ago

patrickmcurry commented 1 year ago

It looks like the ability to get a JSON list of all replies to a post isn't working. I ran into this error trying to make my Mastodon embed tools support Shuttlecraft.

Example of the site talking to a Shuttlecraft instance: https://patrickcurry.com/socials/mastodon/comments/#url=https://social.benbrown.com/notes/eaba2b08d487db8930f56458c5f3638f

And an example of the site talking to my Glitch Shuttlecraft instance: https://patrickcurry.com/socials/mastodon/comments/#url=https://silky-grape-sociology.glitch.me/notes/81ce6027b1e69f81bb21332b8266c64a

Original post JSON view: https://silky-grape-sociology.glitch.me/m/81ce6027b1e69f81bb21332b8266c64a

That JSON lists this URL to get replies: https://silky-grape-sociology.glitch.me/m/81ce6027b1e69f81bb21332b8266c64a/replies

Requesting that URL, even with the MIME type in the request headers, results in: Cannot GET /m/81ce6027b1e69f81bb21332b8266c64a/replies

benbrown commented 1 year ago

yup this is true.

patrickmcurry commented 1 year ago

I'm down to try adding this feature, if ya like @benbrown ?

benbrown commented 1 year ago

@patrickmcurry ok! I think you only want direct replies? Not sure what the spec says. You would do this by groveling over the index of posts which includes the inreplyto field. There is an example of this in action on the public post page.

patrickmcurry commented 1 year ago

Code isn't pretty yet, but I made /notes/:guid/replies return JSON like so: https://silky-grape-sociology.glitch.me/m/81ce6027b1e69f81bb21332b8266c64a/replies

And I edited my rendering code to be able to read and display it like so: https://patrickcurry.com/socials/mastodon/comments/#url=https://silky-grape-sociology.glitch.me/notes/81ce6027b1e69f81bb21332b8266c64a

I didn't put any work into the naming or layout of the return data in JSON. Is there an ActivityPub spec for this type of "list of replies to a post"? Or should we try to mirror the Mastodon API for this (which might be good for eventual Mastodon mobile client support)?

benbrown commented 1 year ago

Yes, there is a prescribed format for this called "Collections" that can optionally include pagination. Take a look here:

https://github.com/benbrown/shuttlecraft/blob/main/routes/outbox.js#L15

benbrown commented 1 year ago

https://www.w3.org/TR/activitypub/#collections

patrickmcurry commented 1 year ago

Sounds good. Looks straightforward.

benbrown commented 1 year ago

@patrickmcurry how goes on this?