dimkr / tootik

A federated nanoblogging service with a Gemini frontend.
gemini://hd.206267.xyz
Apache License 2.0
107 stars 4 forks source link

finding tootik posts #17

Closed snan closed 9 months ago

snan commented 1 year ago

Hi!

I wanted to reply to this post gemini://hd.206267.xyz/view/77572017c3e3303677a7a1430179c23a452d25c91dc5b11b5ce602f531a0e229 from my Akkoma instance but I didn't know what to search for in there.

wget --header 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"' -qO- "htt ps://hd.206267.xyz/user/dimkr"|jq|less

That worked fine, but the outbox address doesn't seem to work:

wget --header 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"' -qO- https://hd.206267.xyz/outbox/dimkr|less

Nor can I do this:

wget --header 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"' -qO- https://hd.206267.xyz/view/77572017c3e3303677a7a1430179c23a452d25c91dc5b11b5ce602f531a0e229 I tried grepping through Tootik's golang source code for hints, too. Tootik is such a good idea. Thank you for starting this project.

dimkr commented 1 year ago

That worked fine, but the outbox address doesn't seem to work:

This API is not implemented (yet?).

Saving of historical data (so you can fetch all posts by a newly-followed user) increases complexity and storage requirements. In addition, your instance should contain this post if you follow the author, because this post is sent to your instance.

(I know, this means you can reply to a post from a tootik instance only if you follow the author, or any other user on the same instance follows the author, otherwise you can't access the post)

I'll see what I can do, it shouldn't be hard to save the Create activity when a new post is created, then implement an /outbox API that lists Create activities by user x.

dimkr commented 1 year ago

@snan Please try now, I implemented basic support for this (no idea how to test compatibility, because I don't know what triggers requests to /outbox/%s in Mastodon)

snan commented 1 year ago

You can try

wget --header 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"' -qO- https://hd.206267.xyz/view/77572017c3e3303677a7a1430179c23a452d25c91dc5b11b5ce602f531a0e229

to test. I still got nothing

dimkr commented 1 year ago

I only implemented /outbox/%s so far, not direct access to posts.

snan commented 1 year ago

You li'l scoundrel ♥ Yeah, outbox works fine now

dimkr commented 1 year ago

@snan Try now, you should be able to fetch posts over HTTPS - the ID of a post is now a working HTTPS URL and not just an opaque identifier

$ curl -s https://hd.206267.xyz/outbox/dimkr | jq -r .first
https://hd.206267.xyz/outbox/dimkr?01694268286

(first page of dimkr's outbox)

$ curl -s https://hd.206267.xyz/outbox/dimkr?01694268286 | jq -r '.orderedItems[0].object.id'
https://hd.206267.xyz/post/8189787ffae14a8bfd03bb2fbb21045adb98265de8784e1f2c910b68ea9d8129

(object ID of first activity in dimkr's outbox, assuming it's a Create activity of a Note object)

$ curl -s https://hd.206267.xyz/post/8189787ffae14a8bfd03bb2fbb21045adb98265de8784e1f2c910b68ea9d8129 | jq
{
  "@context": "https://www.w3.org/ns/activitystreams",
  "attributedTo": "https://hd.206267.xyz/user/dimkr",
  "cc": [
    "https://hd.206267.xyz/followers/dimkr"
  ],
  "content": "Test public post after big refactor",
  "id": "https://hd.206267.xyz/post/8189787ffae14a8bfd03bb2fbb21045adb98265de8784e1f2c910b68ea9d8129",
  "published": "2023-09-09T14:04:46.602422143Z",
  "tag": null,
  "to": [
    "https://www.w3.org/ns/activitystreams#Public"
  ],
  "type": "Note",
  "url": "gemini://hd.206267.xyz/view/83708f1c8cc781380460991578904f5b8dbec95f997490d7a9e160f89c5b3f27"
}

(the Note object associated with this ID)

dimkr commented 1 year ago

More improvements (still not pushed but already deployed in hd.206267.xyz):

  1. Post ID is now a working HTTPS URL and the user is redirected to Gemini if the browser requests HTML
  2. Post title is now link identical to its ID now (previously it wasn't, because tootik did not expose posts over HTTPS and links were broken)
  3. /outbox and /post output is a bit cleaner, because data is saved in a more complete form and gets cleaned up when the HTTP response is built
snan commented 1 year ago

I still haven't been able to pull them into Akkoma, even after all this hard work that you've put in so far.

snan commented 9 months ago

It works now!