fix(startup): move space alias provisioning after loadAllDocs
The IIFE raced with doc loading so listCommunities returned empty. Moved into the .then() callback to ensure all docs are loaded first. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
3596bb9d7c
commit
a5c7eef466
|
|
@ -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(", ")}`);
|
||||
|
|
|
|||
Loading…
Reference in New Issue