feat(federation): server-side acknowledge for reset events (acknowledged_at + admin endpoint) (detach spec §4.6)

This commit is contained in:
Jannis Braun
2026-07-02 18:59:33 +02:00
parent 7e1e32de69
commit 42ad5e141d
10 changed files with 3938 additions and 3 deletions
+32
View File
@@ -1646,6 +1646,7 @@ export async function federationRoutes(app: FastifyInstance): Promise<void> {
resolvedAt: ev.resolvedAt,
stubCount: ev.stubCount,
orphanedAccountCount: ev.orphanedAccountCount,
acknowledgedAt: ev.acknowledgedAt,
orphanedAccounts,
};
});
@@ -1654,6 +1655,37 @@ export async function federationRoutes(app: FastifyInstance): Promise<void> {
},
);
// ─── POST /api/federation/reset-events/acknowledge ─────────────────────────
// Admin-only: dismiss a reset event from the admin banner. Purely
// informational state — detached accounts stay detached and functional;
// acknowledging just stops the surface from re-listing them (detach spec §4.6).
app.post<{ Body: { origin: string } }>(
'/api/federation/reset-events/acknowledge',
{ preHandler: [authenticate, requireAdmin] },
async (request, reply) => {
const { origin } = request.body;
if (!origin || typeof origin !== 'string') {
return reply.code(400).send({ error: 'origin is required', statusCode: 400 });
}
const db = getDb();
const existing = db
.select()
.from(schema.federationResetEvents)
.where(eq(schema.federationResetEvents.origin, origin))
.get();
if (!existing) {
return reply.code(404).send({ error: 'No reset event for this origin', statusCode: 404 });
}
if (existing.acknowledgedAt === null) {
db.update(schema.federationResetEvents)
.set({ acknowledgedAt: Date.now() })
.where(eq(schema.federationResetEvents.origin, origin))
.run();
}
return reply.code(200).send({ success: true });
},
);
// ─── DELETE /api/federation/peers/:id ──────────────────────────────────────
// Admin-only: revoke a federation peer and clean up its outbox.
app.delete<{ Params: { id: string } }>(