feat(settings): expose federatedRegistrationOpen in /settings/instance + /instance/info

Surfaces the federatedRegistrationOpen flag (Task 1 schema column) on the
admin settings GET/PATCH endpoints and the public /api/instance/info
endpoint. Closes the 3 deferred TypeScript errors from Task 2 by
populating the now-required InstanceAdminSettings/InstanceInfoResponse
field.

Adds smoke tests (routes/instance.test.ts, routes/settings.test.ts) that
lock in the JSON contract the Connections UI (Task 21) and admin
RegistrationPanel (Task 15) consume, plus boolean-validation coverage
for the PATCH path. Updates docs/systems/admin.md with the new field in
both InstanceAdminSettings and the public info response schema.
This commit is contained in:
Jannis Braun
2026-04-28 21:01:50 +02:00
parent 87301bd4d2
commit 8d7ba33c21
5 changed files with 267 additions and 1 deletions
+9
View File
@@ -185,6 +185,7 @@ export async function settingsRoutes(app: FastifyInstance): Promise<void> {
const response: InstanceAdminSettings = {
instanceName: row.instanceName ?? 'Backspace',
registrationOpen: row.registrationOpen !== null ? row.registrationOpen === 1 : config.registrationOpen,
federatedRegistrationOpen: row.federatedRegistrationOpen === 1,
discoveryEnabled: row.discoveryEnabled === 1,
gifApiKey: gifKey ? `****${gifKey.slice(-4)}` : undefined,
gifEnabled: !!gifKey,
@@ -216,6 +217,13 @@ export async function settingsRoutes(app: FastifyInstance): Promise<void> {
updateData.registrationOpen = body.registrationOpen ? 1 : 0;
}
if (body.federatedRegistrationOpen !== undefined) {
if (typeof body.federatedRegistrationOpen !== 'boolean') {
return reply.code(400).send({ error: 'federatedRegistrationOpen must be boolean', statusCode: 400 });
}
updateData.federatedRegistrationOpen = body.federatedRegistrationOpen ? 1 : 0;
}
if (body.discoveryEnabled !== undefined) {
updateData.discoveryEnabled = body.discoveryEnabled ? 1 : 0;
}
@@ -276,6 +284,7 @@ export async function settingsRoutes(app: FastifyInstance): Promise<void> {
const response: InstanceAdminSettings = {
instanceName: updatedRow.instanceName ?? 'Backspace',
registrationOpen: updatedRow.registrationOpen !== null ? updatedRow.registrationOpen === 1 : config.registrationOpen,
federatedRegistrationOpen: updatedRow.federatedRegistrationOpen === 1,
discoveryEnabled: updatedRow.discoveryEnabled === 1,
gifApiKey: updatedGifKey ? `****${updatedGifKey.slice(-4)}` : undefined,
gifEnabled: !!updatedGifKey,