this post was submitted on 16 Sep 2025
28 points (100.0% liked)

Fediverse

37170 readers
282 users here now

A community to talk about the Fediverse and all it's related services using ActivityPub (Mastodon, Lemmy, KBin, etc).

If you wanted to get help with moderating your own community then head over to !moderators@lemmy.world!

Rules

Learn more at these websites: Join The Fediverse Wiki, Fediverse.info, Wikipedia Page, The Federation Info (Stats), FediDB (Stats), Sub Rehab (Reddit Migration)

founded 2 years ago
MODERATORS
 

TL;DR: Any of you who are more familiar with Fediverse platforms that aren't Lemmy/Piefed, can you let me know what the AP_IDs look like for users, posts, comments, and, if applicable, communities?

So, I've rewritten the search / search boxes in Tesseract to skip the search and directly resolve activity pub URLs for users, posts, comments, and communities. I'm loving this as it makes things so much faster and easier.

To make that work, and reduce false positives/negatives, I have to do some pre-flight checks on the URL that's submitted to the search.

Currently, it checks if the domain is to a known federated instance and looks for specific paths in the URL. If it detects the URL is an AP_ID URL, it will only resolve the object and redirect you to it (skipping the lengthy search step). For false negatives, it will pass it to the regular search but still try a federated lookup along with the search.

For Lemmy and Piefed, those are:

  • /u/ for users
  • /c/ for communities
  • /post/ for posts
  • /comment/ for comments.

For Mbin, I think it's the same except it uses /m/ for communities (they call them "magazines" I believe).

I think mastoon uses /user or maybe /username/ in the AP identifiers?

Any of you who are more familiar with Fediverse platforms that aren't Lemmy/Piefed, can you let me know what the AP_IDs look like for users, posts, comments, and, if applicable, communities?

you are viewing a single comment's thread
view the rest of the comments
[โ€“] admiralpatrick@lemmy.world 1 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

I think you would be better served by checking for the Link header

Can't really do that, client-side, in a browser application. CORS is a perpetual cockblock (though I understand why it is), and I'd rather not make an internal API endpoint to do the lookup.

The application polls Lemmy's getFederatedInstances API endpoint at startup, so it has a list of every activity pub server your instance knows about. That's the first and primary check for the URL that's being searched.

The second check is just to rule out non activity pub URLs that point to a federated instance (e..g. https://lemmy.world/modlog, https://lemm.world/pictrs/image/blah.webp, etc).

Goal isn't to "catch 'em all" but to catch the most used ones. If there's one I don't account for, either by omission or because the federated platform didn't exist when I made the patterns, then it will just fall back to a regular search which also includes trying to resolve it as a federated URL (which is the current behavior in all prior versions).

The goal is just to simply short-circuit the search behavior if the query is a known ap_id URL in order to avoid a lengthy search process and quickly redirect you to your instance's local copy.

[โ€“] julian@activitypub.space 1 points 2 weeks ago

Can you not call fetch() to do a HEAD call? Maybe I'm mistaken about it but it should be ok.

CORS is indeed a wrench that gets thrown in when you least expect it...