fix: check 202 before response.ok so queued approval isn't treated as accepted
This commit is contained in:
@@ -139,15 +139,6 @@ async function performHandshake(
|
|||||||
signal: AbortSignal.timeout(10_000),
|
signal: AbortSignal.timeout(10_000),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.ok) {
|
|
||||||
// Activate the peer
|
|
||||||
db.update(schema.federationPeers)
|
|
||||||
.set({ status: 'active', lastSeenAt: Date.now() })
|
|
||||||
.where(eq(schema.federationPeers.id, peerId))
|
|
||||||
.run();
|
|
||||||
return { status: 'active', peerId };
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response.status === 202) {
|
if (response.status === 202) {
|
||||||
// Request queued for admin approval on the remote side
|
// Request queued for admin approval on the remote side
|
||||||
db.update(schema.federationPeers)
|
db.update(schema.federationPeers)
|
||||||
@@ -157,6 +148,15 @@ async function performHandshake(
|
|||||||
return { status: 'pending', error: 'Awaiting admin approval on remote instance' };
|
return { status: 'pending', error: 'Awaiting admin approval on remote instance' };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
// 200 = peer accepted and activated
|
||||||
|
db.update(schema.federationPeers)
|
||||||
|
.set({ status: 'active', lastSeenAt: Date.now() })
|
||||||
|
.where(eq(schema.federationPeers.id, peerId))
|
||||||
|
.run();
|
||||||
|
return { status: 'active', peerId };
|
||||||
|
}
|
||||||
|
|
||||||
// Check for explicit rejection (autoAcceptPeering = 0)
|
// Check for explicit rejection (autoAcceptPeering = 0)
|
||||||
let code: string | undefined;
|
let code: string | undefined;
|
||||||
let errorMessage = `Remote rejected peering (HTTP ${response.status})`;
|
let errorMessage = `Remote rejected peering (HTTP ${response.status})`;
|
||||||
|
|||||||
Reference in New Issue
Block a user