From 30eff8e6c7a2e8c321e4e5842f133154a8838436 Mon Sep 17 00:00:00 2001 From: Ricardo Date: Sat, 21 Mar 2026 16:45:58 +0100 Subject: [PATCH] fix: status lookup fails due to published date format mismatch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit findTimelineItemById decoded the cursor (ms-since-epoch) back to an ISO date via toISOString() which produces "2026-03-21T15:33:50.000Z". But the stored published dates lack the .000Z milliseconds suffix — they're "2026-03-21T15:33:50Z". The exact string match failed for every single status, breaking /statuses/:id, /statuses/:id/context, and all interaction endpoints (favourite, boost, bookmark, delete). Fix: try both formats — with .000Z first, then without. --- lib/mastodon/routes/statuses.js | 11 ++++++++++- package.json | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/mastodon/routes/statuses.js b/lib/mastodon/routes/statuses.js index c22102f..22873d4 100644 --- a/lib/mastodon/routes/statuses.js +++ b/lib/mastodon/routes/statuses.js @@ -567,8 +567,17 @@ async function findTimelineItemById(collection, id) { // Try cursor-based lookup first (published date from ms-since-epoch) const publishedDate = decodeCursor(id); if (publishedDate) { - const item = await collection.findOne({ published: publishedDate }); + // Try exact match first (with .000Z suffix from toISOString) + let item = await collection.findOne({ published: publishedDate }); if (item) return item; + + // Try without milliseconds — stored dates often lack .000Z + // e.g., "2026-03-21T15:33:50Z" vs "2026-03-21T15:33:50.000Z" + const withoutMs = publishedDate.replace(/\.000Z$/, "Z"); + if (withoutMs !== publishedDate) { + item = await collection.findOne({ published: withoutMs }); + if (item) return item; + } } // Fall back to ObjectId lookup (legacy IDs) diff --git a/package.json b/package.json index 88b9754..36083ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rmdes/indiekit-endpoint-activitypub", - "version": "3.6.9", + "version": "3.7.0", "description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.", "keywords": [ "indiekit",