fix(federation): enable relay by default — it fixes a bug, not an optional feature

Federation relay was incorrectly defaulting to disabled, requiring
admins to discover a buried settings toggle. Since federation itself
is opt-in (you connect instances manually), relay should be on by
default. Also migrates existing instances from 0 → 1.
This commit is contained in:
Jannis Braun
2026-03-26 03:54:20 +01:00
parent 2b2f64e7f9
commit b34732e064
2 changed files with 11 additions and 2 deletions
+10 -1
View File
@@ -203,7 +203,7 @@ export function runMigrations(db: Database.Database): void {
{
name: 'instance_settings',
columns: [
{ name: 'federation_relay_enabled', type: 'INTEGER NOT NULL DEFAULT 0' },
{ name: 'federation_relay_enabled', type: 'INTEGER NOT NULL DEFAULT 1' },
{ name: 'federation_relay_ttl_days', type: 'INTEGER NOT NULL DEFAULT 30' },
]
},
@@ -483,6 +483,15 @@ export function runMigrations(db: Database.Database): void {
db.exec(`CREATE INDEX IF NOT EXISTS idx_outbox_retry ON federation_outbox(next_retry_at)`);
db.exec(`CREATE INDEX IF NOT EXISTS idx_mutation_log_time ON federation_mutation_log(mutated_at)`);
// ─── Ensure federation relay is enabled (fix: was incorrectly defaulting to 0) ─
try {
const relayState = db.prepare('SELECT federation_relay_enabled FROM instance_settings WHERE id = 1').get() as { federation_relay_enabled: number } | undefined;
if (relayState && relayState.federation_relay_enabled === 0) {
db.prepare('UPDATE instance_settings SET federation_relay_enabled = 1 WHERE id = 1').run();
console.log('Federation: Enabled relay (was incorrectly defaulting to disabled)');
}
} catch { /* column may not exist yet on first run */ }
// ─── Backfill federation mutation log for existing DM messages (idempotent) ─
try {
const mutationLogExists = (db.pragma('table_info(federation_mutation_log)') as { name: string }[]).length > 0;