diff --git a/CLAUDE.md b/CLAUDE.md index 9f718a6..6976363 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -52,7 +52,7 @@ - JSON-LD parent organization is Yivi (not Radboud University). - Outlook-tab copy on `/addons` lives in `src/lib/locales/{en,nl}.json` under `addons.Outlook` (one HTML string) — append new `
  • ` items at the end of the `
      `. - The recipient notification email is generated in `encryption4all/cryptify` (`src/email.rs` + `templates/email/*`), NOT here — `EmailPreviewModal.svelte` only previews cryptify's rendered HTML. And a user complaint about a small/hard-to-copy "code" in an email is usually the Yivi email-attribute verification flow (privacybydesign/irmamobile epic #598), not cryptify's download link — check there before routing. -- `UsageWarning` fires when the SENDER's email becomes known (after `pg.sign.yivi(...)` with `includeSender: true`) — never probe on the first recipient email; quotas are per-sender. Server 413 on `POST /fileupload/finalize/` is the authoritative backstop. +- There is no live pre-flight usage probe. Sender quotas (per-sender) are enforced by the server 413 on `POST /fileupload/finalize/` — parsed by `parseLimitExceededBody` in `src/lib/usage.ts` — with a browser-local estimate in `src/lib/localUsage.ts` for the warning ahead of upload. A `GET /usage` client (`fetchUsage`) and a `UsageWarning` component were sketched but never wired into the UI; the `fetchUsage` remnant was removed (see #323). ## Before claiming tests green diff --git a/src/lib/usage.ts b/src/lib/usage.ts index 8170826..92b618c 100644 --- a/src/lib/usage.ts +++ b/src/lib/usage.ts @@ -1,4 +1,4 @@ -import { FILEHOST_URL, ROLLING_LIMIT } from '$lib/env' +import { ROLLING_LIMIT } from '$lib/env' /** * Response shape of `GET /usage?email=...` on the cryptify backend (see encryption4all/cryptify#100). @@ -37,31 +37,6 @@ export function classifyUsage(u: UsageResponse): UsageStatus { } } -/** - * Fetch the current sender usage from cryptify. Returns null when the endpoint is - * unreachable or unavailable (e.g. backend not yet deployed) so the UI degrades quietly. - * `signal` lets callers cancel in-flight requests when the user keeps typing. - */ -export async function fetchUsage( - email: string, - signal?: AbortSignal -): Promise { - try { - const url = `${FILEHOST_URL}/usage?email=${encodeURIComponent(email)}` - const res = await fetch(url, { signal, credentials: 'omit' }) - if (!res.ok) return null - const body = (await res.json()) as UsageResponse - if ( - typeof body.used_bytes !== 'number' || - typeof body.limit_bytes !== 'number' - ) - return null - return classifyUsage(body) - } catch { - return null - } -} - /** * Parse a cryptify 413 "limit exceeded" response body into a UsageStatus when possible. * Falls back to a synthetic "blocked at `ROLLING_LIMIT`" status so the UI can still show