diff --git a/lib/controllers/compose.js b/lib/controllers/compose.js index e69e115..73dcbe1 100644 --- a/lib/controllers/compose.js +++ b/lib/controllers/compose.js @@ -264,23 +264,28 @@ export function submitComposeController(mountPath, plugin) { object: note, }); - // Resolve recipient for delivery - const { resolveAuthor } = await import("../resolve-author.js"); + // Look up the recipient actor directly (senderActorUrl is an actor URL, not a post URL) const documentLoader = await ctx.getDocumentLoader({ identifier: handle }); - const recipient = await resolveAuthor( - senderActorUrl, - ctx, - documentLoader, - application?.collections, - ); - - if (recipient) { - await ctx.sendActivity({ identifier: handle }, recipient, create, { - orderingKey: noteId.href, - }); - console.info(`[ActivityPub] Sent direct AP reply to ${senderActorUrl}`); + let recipient; + try { + recipient = await ctx.lookupObject(new URL(senderActorUrl), { documentLoader }); + } catch (lookupError) { + console.warn(`[ActivityPub] Actor lookup failed for ${senderActorUrl}:`, lookupError.message); } + // Fall back to a minimal Recipient if lookup fails (standard inbox path) + if (!recipient) { + recipient = { + id: new URL(senderActorUrl), + inboxId: new URL(`${senderActorUrl}/inbox`), + }; + } + + await ctx.sendActivity({ identifier: handle }, recipient, create, { + orderingKey: noteId.href, + }); + console.info(`[ActivityPub] Sent direct AP reply to ${senderActorUrl}`); + return response.redirect(`${mountPath}/admin/reader/notifications`); } catch (error) { console.error("[ActivityPub] Native AP DM reply failed:", error.message);