ihasmail spoke to two generations of Stalwart that are less alike than their version numbers suggest: 0.16 replaced the REST management API with JMAP registry objects, changed the shape of FileNode, split its rights up, and moved configuration into the store. Carrying both meant 34 branch points across nine files, a 92-line compatibility shim whose only job was telling them apart, a parallel REST implementation of every credential operation, and a mock that had to model both. The branches were not the real cost. The cost was that a wrong answer about which generation had answered always had somewhere to fall back to, so it failed quietly rather than loudly: one capability looked for in the wrong place downgraded every real 0.16 server onto the 0.15 path, which posted the current password to an endpoint 0.16 had removed, reported the wrong generation on About, and ran Files on the older code. It reached production and was recorded as verified when it was not. The mock mirrored the same wrong placement, which is why the tests agreed. Removed: the filenode compatibility shim, the dual "registry" | "legacy" backend in account.ts, the pre-0.16 generation in AccountInfo and everything that read it, the mock's LEGACY mode and dev:mock:legacy, and the three test files that existed only to pin 0.15 behaviour. Sign-in now refuses an older server by name, once, rather than letting Files, the account locale and credentials each fail in their own way with nothing connecting them. It says the credentials were fine -- someone hitting this has typed a correct password, and telling them otherwise sends them round in circles -- and names the tag to build from. Four tests cover it, including that no session cookie is minted and that bad credentials on such a server are still a plain 401. Two fallbacks went that were not strictly about 0.15, and both for the same reason the removal is happening. Files no longer answers a refused filter or sort by fetching every node in the account, which would hide a real fault behind a performance cliff nobody would notice. And the app folder lookups now filter on parentId/isTopLevel alone and match names client-side, since `name` is not a filter Stalwart is known to implement and one it does not know fails the whole query rather than being ignored. The last release that runs on 0.15 is tagged stalwart-0.15-support. Verified against the mock end to end: sign-in, the Files tree on the 0.16 path with the app folder hidden, and self-service credentials over the registry. 226 web + 75 server tests pass; typecheck and build clean.
50 lines
2.6 KiB
TypeScript
50 lines
2.6 KiB
TypeScript
import { useSession } from "@/store/session";
|
|
import { client } from "@/jmap/client";
|
|
import { DEFAULT_SOURCE_URL } from "@/lib/source";
|
|
|
|
export function AboutSettings() {
|
|
const session = useSession((s) => s.session);
|
|
const caps = Object.keys(session?.capabilities ?? {});
|
|
// A deployment running modified code should offer its own source, not ours.
|
|
const sourceUrl = session?.ihasmail?.sourceUrl ?? DEFAULT_SOURCE_URL;
|
|
return (
|
|
<div>
|
|
<h1>About ihasmail</h1>
|
|
<p className="lead">A fast, friendly, open-source webmail for <a href="https://stalw.art" target="_blank" rel="noreferrer">Stalwart Mail Server</a>, built on JMAP.</p>
|
|
<div className="row" style={{ gap: 16, alignItems: "center", marginBottom: 16 }}>
|
|
<img src="/img/logo.png" alt="ihasmail" width={96} />
|
|
<div>
|
|
<div style={{ fontWeight: 700, fontSize: "1.2em" }}>ihasmail 2.0</div>
|
|
<div className="hint">AGPL-3.0-or-later · <a href={sourceUrl} target="_blank" rel="noreferrer">{sourceUrl.replace(/^https?:\/\//, "")}</a></div>
|
|
</div>
|
|
</div>
|
|
<h2>Server</h2>
|
|
<table className="sessions-table">
|
|
<tbody>
|
|
<tr><td>Signed in as</td><td>{session?.username}</td></tr>
|
|
<tr><td>Stalwart</td><td>{describeServer(session?.ihasmail?.server)}</td></tr>
|
|
<tr><td>Accounts</td><td>{Object.values(session?.accounts ?? {}).map((a) => a.name).join(", ")}</td></tr>
|
|
<tr><td>Max upload</td><td>{Math.round(client.maxSizeUpload / 1048576)} MB</td></tr>
|
|
<tr><td>Image privacy proxy</td><td>{session?.ihasmail?.imageProxy ? "enabled" : "disabled"}</td></tr>
|
|
</tbody>
|
|
</table>
|
|
<p className="hint" style={{ marginTop: 6 }}>Stalwart does not publish its version number to mail clients, so ihasmail reports the edition where the server gives one. ihasmail requires 0.16 or newer, and sign-in refuses anything older.</p>
|
|
<h2>Server capabilities</h2>
|
|
<div className="row wrap gap-4">
|
|
{caps.map((c) => <span key={c} className="chip mono" style={{ fontSize: ".78em" }}>{c.replace("urn:ietf:params:jmap:", "")}</span>)}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Stalwart deliberately withholds its version from clients (it reports a fixed
|
|
* "1.0.0" wherever it publishes one at all), so the edition is all there is to
|
|
* show. The generation used to be reported here too, back when ihasmail spoke
|
|
* to both 0.15 and 0.16; it requires 0.16 now, so signing in at all is the
|
|
* answer to that question.
|
|
*/
|
|
function describeServer(server: { edition?: string | null } | undefined): string {
|
|
return server?.edition ? `0.16 or newer (${server.edition})` : "0.16 or newer";
|
|
}
|