feat: store outbound DMs in ap_notifications for threading; redirect to ?tab=mention
This commit is contained in:
@@ -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", {
|
||||
|
||||
Reference in New Issue
Block a user