feat(federation): add client peering integration, transparency indicator, and admin federation settings

Task 13: Hook server-to-server peering into connectToRemote (non-fatal)
and add federation API namespace to the client (initiate, peers, revoke).

Task 14: Show a transparency notice in the DM welcome header when the
other user is on a remote instance, informing that messages are stored
on both home instances and are not end-to-end encrypted.

Task 15: Add Federation section to the instance settings General panel
with DM relay toggle, TTL config, and a live peer list with revoke
buttons. Also extends InstanceAdminSettings type and the server settings
route to support federationRelayEnabled / federationRelayTtlDays.
This commit is contained in:
Jannis Braun
2026-03-25 21:47:10 +01:00
parent 3898e4940a
commit 44de9b6f41
6 changed files with 215 additions and 2 deletions
+16
View File
@@ -189,6 +189,8 @@ export async function settingsRoutes(app: FastifyInstance): Promise<void> {
gifApiKey: gifKey ? `****${gifKey.slice(-4)}` : undefined,
gifEnabled: !!gifKey,
maxUploadSizeMb: Math.round(maxUploadBytes / (1024 * 1024)),
federationRelayEnabled: row.federationRelayEnabled === 1,
federationRelayTtlDays: row.federationRelayTtlDays,
};
return reply.code(200).send(response);
@@ -235,6 +237,18 @@ export async function settingsRoutes(app: FastifyInstance): Promise<void> {
updateData.maxUploadSizeBytes = Math.round(mb * 1024 * 1024);
}
if (body.federationRelayEnabled !== undefined) {
updateData.federationRelayEnabled = body.federationRelayEnabled ? 1 : 0;
}
if (body.federationRelayTtlDays !== undefined) {
const ttl = Number(body.federationRelayTtlDays);
if (isNaN(ttl) || !Number.isInteger(ttl) || ttl < 1 || ttl > 365) {
return reply.code(400).send({ error: 'federationRelayTtlDays must be an integer between 1 and 365', statusCode: 400 });
}
updateData.federationRelayTtlDays = ttl;
}
db.update(schema.instanceSettings).set(updateData).where(eq(schema.instanceSettings.id, 1)).run();
const updatedRow = db.select().from(schema.instanceSettings).where(eq(schema.instanceSettings.id, 1)).get();
@@ -251,6 +265,8 @@ export async function settingsRoutes(app: FastifyInstance): Promise<void> {
gifApiKey: updatedGifKey ? `****${updatedGifKey.slice(-4)}` : undefined,
gifEnabled: !!updatedGifKey,
maxUploadSizeMb: Math.round(updatedMaxUploadBytes / (1024 * 1024)),
federationRelayEnabled: updatedRow.federationRelayEnabled === 1,
federationRelayTtlDays: updatedRow.federationRelayTtlDays,
};
return reply.code(200).send(response);