Conversation
The posts UI found a post by listing `?q=source` and searching the page for its uid. That page is capped by the cursor’s default limit of 40, so any older post returned 404 when viewed, edited or deleted. Read the posts collection by `_id` instead. Invalid ids and a missing database still return false, so the not-found path is unchanged. Fixes #924
|
@rmdes The reason for the current implementation is so that This PR ties the posts endpoint directly to the database, which is what I was trying to avoid. Should Indiekit support third-party Micropub servers? Some (many?) may not provide all the features needs to power the posts interface, and makes Indiekit all the more complex. But supporting third party endpoints feels like we’re following the ethos of the IndieWeb. It’s a good question, and open to thoughts! |
|
You're right about the intent, and digging into the history I think this is a regression rather than a design disagreement. Until micropubUrl.searchParams.append("q", "source");
micropubUrl.searchParams.append("url", getPostUrl(id));One post, fetched by URL. That's exactly the query the Micropub spec defines — "include the URL of the post in the Since that commit we ask for The awkward part is the identifier. So I'd rather ask than assume: what drove the move to uid in Happy to rework this either way:
One caveat on (2), so it isn't oversold: resolving id → url needs something that maps an ObjectId to a post URL, and against a third-party endpoint that's the same chicken-and-egg — the only way to learn the URL for an unknown id is the paginated listing we're trying to stop relying on. So (2) fixes the 404 and restores spec compliance for Indiekit's own store, but only (1) actually decouples the per-post routes from our database. (2) is the smaller, safer step; (1) is the one that delivers the goal. I'd default to (2) to keep your 2023 decision about route shape intact, but if third-party support is the priority then (1) is the honest answer. |
|
Looking into this, I think one of the primary reasons to use ObjectID was that it’s date sortable, whereas an encoded URL isn’t. I’m wondering if the way forward is for Indiekit to include This could then also be the first step to removing support for MongoDB, as we could index on that UUID instead of ObjectIDs. We’d possibly need a way to migrate from I wonder if a Micropub server doesn’t return posts with Thoughts? |
|
UUIDv7 keeps the sortability ObjectId was giving you — 48-bit millisecond prefix, so lexicographic order is time order. It also removes the awkward part of going backend-agnostic. In #917 the only seam the collection interface needed was id casting — One migration detail worth catching: On the Happy to take the migration — UUIDv7 for new posts, backfilled from the ObjectId timestamp so ordering survives, |
|
Yeah, let's do a separate PR. I started investigating this myself, but would like to see your take. Should make it easier for me to review too, having now dug into the code a bit. |
Fixes #924.
getPostPropertiesnow reads thepostscollection by_id(getObjectIdfrom@indiekit/util). Invalid ids and a missing database returnfalseas before, so the 404 path is unchanged.mainwith404 !== 200.?q=sourcelisting now seed a post in the test database; the unused interceptor is removed from the mock agent.getPostProperties(found, not found, invalid id, no database).Verified locally:
node --test packages/endpoint-posts/test/**/*.js37/37, eslint and prettier clean.