Files
indiekit-endpoint-activitypub/lib/controllers/federation-delete.js
Ricardo 1dc42ad5e5 feat: outbound Delete, visibility addressing, CW/sensitive, polls, Flag reports (v2.10.0)
- Outbound Delete: broadcastDelete() + POST /admin/federation/delete route
- Visibility: unlisted + followers-only addressing via defaultVisibility config
- Content Warning: outbound sensitive flag + summary as CW text
- Polls: inbound Question/poll parsing with progress bar rendering
- Flag: inbound report handler with ap_reports collection + Reports tab
- Includes DM support files from v2.9.x (messages controller, storage, templates)
- Includes coverage audit and high-impact gaps implementation plan

Confab-Link: http://localhost:8080/sessions/cc343b15-8d10-43cd-a48f-ca912eb79b83
2026-03-14 08:51:44 +01:00

56 lines
1.4 KiB
JavaScript

/**
* POST /admin/federation/delete — Send Delete activity to all followers.
* Removes a post from the fediverse after local deletion.
* @param {string} mountPath - Plugin mount path
* @param {object} plugin - ActivityPub plugin instance
*/
import { validateToken } from "../csrf.js";
export function deleteFederationController(mountPath, plugin) {
return async (request, response, next) => {
try {
if (!validateToken(request)) {
return response.status(403).json({
success: false,
error: "Invalid CSRF token",
});
}
const { url } = request.body;
if (!url) {
return response.status(400).json({
success: false,
error: "Missing post URL",
});
}
try {
new URL(url);
} catch {
return response.status(400).json({
success: false,
error: "Invalid post URL",
});
}
if (!plugin._federation) {
return response.status(503).json({
success: false,
error: "Federation not initialized",
});
}
await plugin.broadcastDelete(url);
if (request.headers.accept?.includes("application/json")) {
return response.json({ success: true, url });
}
const referrer = request.get("Referrer") || `${mountPath}/admin/activities`;
return response.redirect(referrer);
} catch (error) {
next(error);
}
};
}