Skip to content
This repository was archived by the owner on Jul 28, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<li>` items at the end of the `<ol>`.
- 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/<uuid>` 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/<uuid>`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

Expand Down
27 changes: 1 addition & 26 deletions src/lib/usage.ts
Original file line number Diff line number Diff line change
@@ -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).
Expand Down Expand Up @@ -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<UsageStatus | null> {
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
Expand Down
Loading