diff --git a/server/index.ts b/server/index.ts index 11661d4..90dade4 100644 --- a/server/index.ts +++ b/server/index.ts @@ -3755,6 +3755,23 @@ loadAllDocs(syncServer) } catch (e) { console.error("[TokenService] Seed failed:", e); } + + // Provision Mailcow forwarding aliases for all existing spaces + const ENCRYPTID_INTERNAL_FOR_ALIAS = process.env.ENCRYPTID_INTERNAL_URL || "http://encryptid:3000"; + try { + const slugs = await listCommunities(); + let count = 0; + for (const slug of slugs) { + if (slug === "demo") continue; + try { + await fetch(`${ENCRYPTID_INTERNAL_FOR_ALIAS}/api/internal/spaces/${slug}/alias`, { method: "POST" }); + count++; + } catch { /* encryptid not ready yet, will provision on next restart */ } + } + if (count > 0) console.log(`[SpaceAlias] Provisioned ${count} space aliases`); + } catch (e) { + console.error("[SpaceAlias] Startup provisioning failed:", e); + } }) .catch((e) => console.error("[DocStore] Startup load failed:", e)); @@ -3779,24 +3796,5 @@ loadAllDocs(syncServer) } })(); -// Provision Mailcow forwarding aliases for all existing spaces -const ENCRYPTID_INTERNAL_FOR_ALIAS = process.env.ENCRYPTID_INTERNAL_URL || "http://encryptid:3000"; -(async () => { - try { - const slugs = await listCommunities(); - let count = 0; - for (const slug of slugs) { - if (slug === "demo") continue; - try { - await fetch(`${ENCRYPTID_INTERNAL_FOR_ALIAS}/api/internal/spaces/${slug}/alias`, { method: "POST" }); - count++; - } catch { /* encryptid not ready yet, will provision on next restart */ } - } - if (count > 0) console.log(`[SpaceAlias] Provisioned ${count} space aliases`); - } catch (e) { - console.error("[SpaceAlias] Startup provisioning failed:", e); - } -})(); - console.log(`rSpace unified server running on http://localhost:${PORT}`); console.log(`Modules: ${getAllModules().map((m) => `${m.icon} ${m.name}`).join(", ")}`);