mirror of
https://github.com/svemagie/indiekit-endpoint-activitypub.git
synced 2026-04-02 15:44:58 +02:00
- 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
56 lines
1.4 KiB
JavaScript
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);
|
|
}
|
|
};
|
|
}
|