Rework the sidebar "All accounts" section into a "Unified Mailbox" that, by default, stays within the active login account and its shared/group folders. Merging across multiple logged-in accounts becomes an opt-in sub-option instead of the default, and the standalone per-account "All Mail" virtual folder is folded into the unified All mail / Unread / Starred entries (its folder selection now narrows those lists). Scope: - lib/unified-mailbox.ts: UnifiedAccountClient.crossIncludedMailboxIds; the cross views honor the per-account folder selection (union across accounts = the sum of each account's selection), falling back to inbox+custom when unset. - stores/email-store.ts: buildUnifiedAccountClients gains scopeToClientAccountId (the account boundary) and populates crossIncludedMailboxIds from allMailFolderIds; remove the standalone __all_mail__ fetch/search/load-more branches. - page.tsx: scope to the active account unless cross-account is active (per-user opt-in AND admin gate); the per-role unified mailboxes obey the same scope. Folding: - Drop ALL_MAIL_MAILBOX_ID (lib/jmap/types.ts); thread-list source-folder column now keys on isUnifiedView only; settings folder picker moves under the unified group and shows once any unified entry is enabled. Config: - User: new unifiedCrossAccount (default false); includeGroupInUnified default flips to true; enableAllMailView retired; the three cross-view toggles now gate the unified Unread/Starred/All mail entries. - Admin: new unifiedCrossAccountEnabled gate, default FALSE (cross-account is an admin opt-in; when off the per-user toggle is hidden and the scope is forced account-bounded at runtime). allMailViewEnabled deprecated and normalized forward into crossAllViewEnabled on policy load; cross-view gate labels reworded to "Unified Mailbox: ...". Header: the sidebar section shows "All accounts" when cross-account is active (opt-in AND admin gate AND >1 connected account), else "Unified Mailbox". Migration: - Settings persist v5 -> v6 (exported migrateSettings) - cross-active users keep cross-account; All-Mail-only users get the account-bounded unified All mail entry with folder ids preserved; includeGroupInUnified enabled for every migrated config; fresh installs are account-bounded. - Admin policy: one-shot, marker-guarded migratePolicyUnifiedMailbox (run before configManager.load) enables unifiedCrossAccountEnabled when a cross view was active, so existing cross-account installs keep the behaviour despite the default-false gate. Skipped on read-only config dirs. Locales: sidebar all_accounts (original label) + unified_mailbox (translated, per locale) keys; dead standalone all_mail strings removed across all 20 locales. Docs: FEATURES.md updated to the account-bounded model, the cross-account gate, and the folder-narrowed aggregate entries. Verification: tsc clean, eslint clean, full vitest suite green (incl. translations completeness, cross-view/migration coverage, and the admin policy migration test).
64 lines
2.7 KiB
TypeScript
64 lines
2.7 KiB
TypeScript
import { readFileSync } from "fs";
|
|
import { configManager } from "./lib/admin/config-manager";
|
|
import { initAdminPassword } from "./lib/admin/password";
|
|
import { migrateLegacyAdminLayout, migratePolicyUnifiedMailbox } from "./lib/admin/migrate";
|
|
import { detectSetupState } from "./lib/setup/state";
|
|
import { ensureSetupToken } from "./lib/setup/token";
|
|
|
|
const pkg = JSON.parse(
|
|
readFileSync(`${process.cwd()}/package.json`, "utf-8")
|
|
);
|
|
const current: string = pkg.version ?? "0.0.0";
|
|
console.info(`Bulwark Webmail v${current}`);
|
|
|
|
// Initialize admin config and password bootstrap. Migration runs first so
|
|
// existing v1 layouts are split before anything reads admin.json.
|
|
migrateLegacyAdminLayout()
|
|
.then(() => migratePolicyUnifiedMailbox())
|
|
.then(() => configManager.load())
|
|
.then(() => initAdminPassword())
|
|
.then(async () => {
|
|
console.info("Admin dashboard initialized");
|
|
// If we're in bootstrap state (no JMAP_SERVER_URL env and no
|
|
// setupComplete in config.json), generate/refresh the setup token and
|
|
// print it to the logs so the operator can complete the web wizard
|
|
// without execing into the container.
|
|
if (detectSetupState() === "bootstrap") {
|
|
try {
|
|
const token = await ensureSetupToken();
|
|
const port = process.env.PORT || "3000";
|
|
console.info("");
|
|
console.info("==============================================================");
|
|
console.info(" SETUP REQUIRED");
|
|
console.info(` Token: ${token}`);
|
|
console.info(` Open: http://<host>:${port}/setup?token=${token}`);
|
|
console.info(" Token expires in 1 hour. Restart the container to reissue.");
|
|
console.info("==============================================================");
|
|
console.info("");
|
|
} catch (err) {
|
|
console.warn(
|
|
"Failed to issue setup token:",
|
|
err instanceof Error ? err.message : err,
|
|
);
|
|
}
|
|
}
|
|
})
|
|
.then(async () => {
|
|
// Anonymous telemetry - on by default. Admins can disable via the
|
|
// admin UI, the BULWARK_TELEMETRY env var, or by clearing the endpoint.
|
|
// See https://bulwarkmail.org/docs/legal/privacy/telemetry
|
|
const { startScheduler, markProcessStart } = await import("./lib/telemetry");
|
|
markProcessStart();
|
|
await startScheduler();
|
|
})
|
|
.then(async () => {
|
|
// Hourly check against version.telemetry.bulwarkmail.org. Disable with
|
|
// BULWARK_UPDATE_CHECK=off or override the endpoint with
|
|
// BULWARK_UPDATE_CHECK_URL.
|
|
const { startScheduler } = await import("./lib/version-check");
|
|
await startScheduler();
|
|
})
|
|
.catch((err) => {
|
|
console.warn("Admin dashboard init skipped:", err instanceof Error ? err.message : err);
|
|
});
|