From 6afad97bd1f912ffecc4c5d6073b854d3c561c68 Mon Sep 17 00:00:00 2001 From: Jannis Braun <151788261+TheZwiss@users.noreply.github.com> Date: Mon, 20 Apr 2026 18:08:05 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20revert=20outgoing=20peering=20blocks=20?= =?UTF-8?q?=E2=80=94=20autoAcceptPeering=20only=20gates=20incoming?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit autoAcceptPeering means 'don't accept peering initiated by others', not 'don't initiate peering ourselves'. Two checks were incorrectly blocking outgoing peering when auto-accept was off: 1. ensurePeered() refused to auto-initiate — reverted. When a local user sends a DM, the server should initiate peering. The remote's peer/accept decides whether to accept or queue. 2. queueOutboxEvent() refused to create placeholders — reverted. The outbox needs placeholders to queue entries. Without them, DM relay silently fails. --- packages/server/src/utils/federationOutbox.ts | 17 +++++------------ packages/server/src/utils/federationPeering.ts | 16 ---------------- 2 files changed, 5 insertions(+), 28 deletions(-) diff --git a/packages/server/src/utils/federationOutbox.ts b/packages/server/src/utils/federationOutbox.ts index 64d9d7ec..9fe2bec2 100644 --- a/packages/server/src/utils/federationOutbox.ts +++ b/packages/server/src/utils/federationOutbox.ts @@ -151,24 +151,17 @@ export function queueOutboxEvent( ? peers.filter(p => targetPeerOrigins.includes(p.origin)) : peers; - // For targeted origins with no existing peer record, create pending placeholders - // (only when autoAcceptPeering is enabled — otherwise the admin controls all peering) + // For targeted origins with no existing peer record, create pending placeholders. + // autoAcceptPeering controls INCOMING acceptance, not outgoing initiation — + // when a local user sends a DM requiring relay, the server creates the placeholder + // regardless of the setting. The peer/accept gate on the REMOTE side decides + // whether to accept or queue our request. if (targetPeerOrigins) { - const autoAcceptSettings = db - .select({ autoAcceptPeering: schema.instanceSettings.autoAcceptPeering }) - .from(schema.instanceSettings) - .where(eq(schema.instanceSettings.id, 1)) - .get(); - const autoAcceptPeering = (autoAcceptSettings?.autoAcceptPeering ?? 1) === 1; - const matchedOrigins = new Set(matchedPeers.map(p => p.origin)); for (const origin of targetPeerOrigins) { if (matchedOrigins.has(origin)) continue; - // Don't auto-create placeholders when autoAcceptPeering is off - if (!autoAcceptPeering) continue; - // Check if there's a rejected/revoked peer we should skip const existingPeer = db .select({ status: schema.federationPeers.status }) diff --git a/packages/server/src/utils/federationPeering.ts b/packages/server/src/utils/federationPeering.ts index aa3de186..1fc49761 100644 --- a/packages/server/src/utils/federationPeering.ts +++ b/packages/server/src/utils/federationPeering.ts @@ -80,22 +80,6 @@ export async function ensurePeered(origin: string): Promise } } - // When autoAcceptPeering is disabled, don't auto-initiate new peering. - // The admin's intent is "I control all peering" — both incoming (gated by - // peer/accept) and outgoing auto-initiation (gated here). Only the admin - // peer/initiate endpoint and the approval-request approve endpoint bypass - // this check because those represent explicit admin action. - if (!existing) { - const settings = db - .select({ autoAcceptPeering: schema.instanceSettings.autoAcceptPeering }) - .from(schema.instanceSettings) - .where(eq(schema.instanceSettings.id, 1)) - .get(); - if ((settings?.autoAcceptPeering ?? 1) === 0) { - return { status: 'failed', error: 'Auto-peering is disabled on this instance — an admin must initiate peering manually' }; - } - } - // Deduplicate: if a handshake is already in flight, share the promise const inflight = inFlightPeering.get(normalized); if (inflight) {