while rewriting @OCRbot i rediscovered some !!fun!! aspects of writing software for the fediverse.
here's the main one: statuses (toots/posts/notes/wugs) have an in_reply_to_id when they're replies to something. however, if you're on instance A, and John Tooter from instance B replies to Jane Noter on instance C (or maybe even B as well? not sure), the in_reply_to_id will be null -- the same as if John hadn't replied to anyone. OCRbot used to solve this in a janky way that involved trying to scrape the images from instance C, which often failed because instance C's admins had (rightfully!) blocked bots from downloading their images.
to fix this, you need to:
- parse the URL of John's post to determine the instance URL (easy) and remote status ID (easy if John's using Mastodon)
- connect to John's instance's mastodon API
- fetch John's post using (what you assume is) its ID
- hope the other instance a) runs mastodon, b) doesn't block anonymous API clients, c) doesn't block your user agent, and d) actually works
- get John's post as a
statusobject according to his instance - use that to find the real
in_reply_to_id - at this point, you might find that
in_reply_to_idis stillnull. this means that John genuinely didn't reply to anyone. thanks for playing, better luck next time - use the
in_reply_to_idto fetch instance B's representation of Jane's post (remember Jane?) - use that
statusto get auri, which is somehow different to aurl - use your original instance to run a
searchcommand and search for instance B's URL representation of Jane's post withresolve=True. this will cause instance A to (attempt to!) federate Jane's post - now instance A has Jane's post!!!! you can finally download the images
if anyone knows of a better way to do this, i'm all ears. due to Unnamed Past Incidents i do not consider manually using WebFinger (yes it's called that) and parsing ActivityPub JSON files to be "a better way".
@lynnesbian @OCRbot
What about FEP f228 on backfilling conversations?
https://codeberg.org/fediverse/fep/src/branch/main/fep/f228/fep-f228.md
For example, fetch this toot:
https://mastodon.online/@virtualbri/117656731437820525
It has a property called "context", the value of which is "https://mastodon.online/contexts/112168465136244484-117656518870221162".
If you fetch that URL, it's a Collection of the IDs of every post in that thread.
I guess it's not in a particular order, though.
fep/fep/f228/fep-f228.md at main