fix(broker): show mesh slugs in /meshes + /status, remove all-meshes fallback
Some checks failed
CI / Lint (push) Has been cancelled
CI / Typecheck (push) Has been cancelled
CI / Broker tests (Postgres) (push) Has been cancelled
CI / Docker build (linux/amd64) (push) Has been cancelled

- /meshes and /status now show mesh slug names instead of truncated IDs
- meshSlug cached on connect and loaded from DB join on boot
- Remove dangerous fallback that connected to ALL meshes in email flow
- BridgeRow now includes optional meshSlug field

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alejandro Gutiérrez
2026-04-10 02:24:55 +01:00
parent 5df2664bae
commit a022da1998
2 changed files with 15 additions and 11 deletions

View File

@@ -4124,14 +4124,17 @@ function main(): void {
const rows = await db.select({
chatId: telegramBridge.chatId,
meshId: telegramBridge.meshId,
meshSlug: mesh.slug,
memberId: telegramBridge.memberId,
pubkey: telegramBridge.pubkey,
secretKey: telegramBridge.secretKey,
displayName: telegramBridge.displayName,
chatType: telegramBridge.chatType,
chatTitle: telegramBridge.chatTitle,
}).from(telegramBridge).where(eq(telegramBridge.active, true));
return rows.map(r => ({ ...r, chatId: Number(r.chatId) }));
}).from(telegramBridge)
.leftJoin(mesh, eq(telegramBridge.meshId, mesh.id))
.where(eq(telegramBridge.active, true));
return rows.map(r => ({ ...r, meshSlug: r.meshSlug ?? undefined, chatId: Number(r.chatId) }));
},
async (row) => {
await db.insert(telegramBridge).values({
@@ -4170,12 +4173,7 @@ function main(): void {
const byUserId = await db.select({ meshId: meshMember.meshId })
.from(meshMember).where(and(eq(meshMember.userId, userId), isNull(meshMember.revokedAt)));
for (const m of byUserId) meshIds.add(m.meshId);
// Fallback: if user has no members, check all meshes (owner bootstraps)
if (meshIds.size === 0) {
const allMeshes = await db.select({ id: mesh.id }).from(mesh);
for (const m of allMeshes) meshIds.add(m.id);
log.info("tg-email-connect: no member found, trying all meshes", { email, userId, meshCount: meshIds.size });
}
// No fallback user must be an explicit member of a mesh
if (meshIds.size === 0) return [];
const existingMembers = Array.from(meshIds).map(meshId => ({ meshId }));