fix: support plain-object collections in resolveAuthor (Mastodon Client API like/reblog)

resolveAuthor() called collections.get("ap_timeline") assuming a Map, but
the Mastodon Client API passes collections as a plain object
(req.app.locals.mastodonCollections). This caused "collection.get is not a
function" on every favourite/reblog action from Mastodon clients (Phanpy,
Elk, etc.). Now checks typeof collections.get before deciding which access
pattern to use.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
svemagie
2026-03-22 20:28:12 +01:00
parent a37bece8cd
commit 0a686d7ab4

View File

@@ -92,8 +92,8 @@ export async function resolveAuthor(
// Strategy 2: Use author URL from timeline or notifications
if (collections) {
const ap_timeline = collections.get("ap_timeline");
const ap_notifications = collections.get("ap_notifications");
const ap_timeline = typeof collections.get === "function" ? collections.get("ap_timeline") : collections.ap_timeline;
const ap_notifications = typeof collections.get === "function" ? collections.get("ap_notifications") : collections.ap_notifications;
// Search timeline by both uid (canonical) and url (display)
let authorUrl = null;