From ba144da14c089fc7a84314ea7f161c558ced087b Mon Sep 17 00:00:00 2001 From: svemagie <869694+svemagie@users.noreply.github.com> Date: Fri, 13 Mar 2026 07:26:25 +0100 Subject: [PATCH] feat: store outbound DMs in ap_notifications for threading; redirect to ?tab=mention --- lib/controllers/compose.js | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/controllers/compose.js b/lib/controllers/compose.js index 73dcbe1..ab319d9 100644 --- a/lib/controllers/compose.js +++ b/lib/controllers/compose.js @@ -5,6 +5,7 @@ import { Create, Note, Mention } from "@fedify/fedify/vocab"; import { getToken, validateToken } from "../csrf.js"; import { sanitizeContent } from "../timeline-store.js"; +import { addNotification } from "../storage/notifications.js"; function createPublicationAwareDocumentLoader(documentLoader, publicationUrl) { if (typeof documentLoader !== "function") { @@ -286,7 +287,33 @@ export function submitComposeController(mountPath, plugin) { }); console.info(`[ActivityPub] Sent direct AP reply to ${senderActorUrl}`); - return response.redirect(`${mountPath}/admin/reader/notifications`); + // Store outbound DM so it appears in the thread view + try { + const ap_notifications = application?.collections?.get("ap_notifications"); + if (ap_notifications) { + const hostname = new URL(plugin._publicationUrl).hostname; + await addNotification({ ap_notifications }, { + uid: noteId.href, + url: noteId.href, + type: "mention", + isDirect: true, + direction: "outbound", + senderActorUrl, + actorUrl: actorUri.href, + actorName: plugin.options?.actor?.name || handle, + actorPhoto: plugin.options?.actor?.icon || "", + actorHandle: `@${handle}@${hostname}`, + inReplyTo: inReplyTo || null, + content: { text: content.trim(), html: content.trim() }, + published: new Date().toISOString(), + createdAt: new Date().toISOString(), + }); + } + } catch (storeError) { + console.warn("[ActivityPub] Failed to store outbound DM:", storeError.message); + } + + return response.redirect(`${mountPath}/admin/reader/notifications?tab=mention`); } catch (error) { console.error("[ActivityPub] Native AP DM reply failed:", error.message); return response.status(500).render("error", {