fix: compute target origins for 1-on-1 DMs so pending peers are created
getGroupDmTargetOrigins() returned undefined for 1-on-1 DMs, which queueOutboxEvent() treated as 'broadcast to all existing peers'. When no peers existed, nothing was queued and no handshake was ever triggered. Now always computes target origins from DM participants so the pending placeholder creation path runs, enabling ensurePeered() → peer/accept → approval queue flow.
This commit is contained in:
@@ -330,21 +330,23 @@ export function getGroupDmTargetOrigins(dmChannelId: string): string[] | undefin
|
|||||||
.where(eq(schema.dmChannels.id, dmChannelId))
|
.where(eq(schema.dmChannels.id, dmChannelId))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
// Not a group DM (no owner) — broadcast to all
|
// Always compute target origins from participants — both 1-on-1 and group DMs.
|
||||||
if (!channel?.ownerId) return undefined;
|
// Returning undefined (broadcast to all) would skip the pending-placeholder creation
|
||||||
|
// in queueOutboxEvent(), preventing relay when no peer exists yet.
|
||||||
const participants = getDmParticipants(dmChannelId);
|
const participants = getDmParticipants(dmChannelId);
|
||||||
const ourOrigin = getOurOrigin();
|
const ourOrigin = getOurOrigin();
|
||||||
|
|
||||||
const origins = new Set<string>();
|
const origins = new Set<string>();
|
||||||
for (const p of participants) {
|
for (const p of participants) {
|
||||||
// Normalize homeInstance to full URL format to match federation_peers.origin
|
|
||||||
const normalized = p.homeInstance.startsWith('http') ? p.homeInstance : `https://${p.homeInstance}`;
|
const normalized = p.homeInstance.startsWith('http') ? p.homeInstance : `https://${p.homeInstance}`;
|
||||||
if (normalized !== ourOrigin) {
|
if (normalized !== ourOrigin) {
|
||||||
origins.add(normalized);
|
origins.add(normalized);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No remote participants — no relay needed
|
||||||
|
if (origins.size === 0) return undefined;
|
||||||
|
|
||||||
return Array.from(origins);
|
return Array.from(origins);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user