Skip to content

feat: warn users approaching upload limits and block at 5 GB#91

Closed
dobby-coder[bot] wants to merge 1 commit into
mainfrom
feat/upload-limit-warnings
Closed

feat: warn users approaching upload limits and block at 5 GB#91
dobby-coder[bot] wants to merge 1 commit into
mainfrom
feat/upload-limit-warnings

Conversation

@dobby-coder

@dobby-coder dobby-coder Bot commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #87.

Adds UI feedback for upload-limit states described in the issue:

  • Warning banner on the fileshare page when a user has used ≥3.3 GB of their 5 GB 2-week rolling limit (shown when the limit API reports usage ≥ 2/3 of the cap).
  • Hard-block banner when the user has reached the 5 GB limit, with the reset date.
  • Per-upload 5 GB error, surfaced inline in the file picker the moment the total selection crosses MAX_UPLOAD_SIZE. Previously the validation dialog only showed it on clicking Send.
  • Server-blocked banner rendered when cryptify returns 413 (see Enforce server-side upload limits: 5 GB rolling per email (14 days) cryptify#100). This replaces the generic "Something went wrong" page for rejected-by-quota uploads.

Files

  • src/lib/usage.ts — new utility. fetchUsage(email) consumes GET /usage?email=... from cryptify (shape agreed in the coordination note for the upload-limits initiative). Quiet-fails to null if the backend isn't deployed yet. parseLimitExceededBody(body) decodes cryptify's 413 body into a UsageStatus.
  • src/lib/components/filesharing/UsageWarning.svelte — debounced banner (500 ms). Renders nothing when usage is below the warn threshold.
  • src/lib/components/filesharing/SendButton.svelte — wires in UsageWarning, handles 413 gracefully.
  • src/lib/components/filesharing/inputs/FileInput.svelte — adds the inline per-upload error, and the "max 5 GB" text now derives from MAX_UPLOAD_SIZE instead of being hard-coded.
  • src/lib/env.ts — adds ROLLING_LIMIT (VITE_ROLLING_LIMIT, defaults to 5 GB), ready for Upgrade max upload size to 5 GB with 5 GB per 2-week rolling limit #85.
  • src/lib/locales/{en,nl}.json — new usage.* and fileBox.overLimit* keys; maxSizeText now takes a {max} argument.

Open design question for @rubenhensen

The issue says "proactive check on email input: when the user types their email address, query the backend". The 5 GB limit is tracked per sender email (per cryptify#100). The fileshare UI today has no sender email input — the sender's identity only becomes known after Yivi signing.

This PR wires the proactive check to the first recipient's email as a best-effort hook. It's semantically imperfect (recipient ≠ sender), but it lets the component and the endpoint integration land now. The two proper fixes for follow-up:

  1. Add a visible sender email input to the fileshare page, bind UsageWarning to it.
  2. Run the usage check after Yivi sign completes — i.e., accept that the warning is post-hoc for a first-time user but proactive for returning users if we cache the last-used sender in localStorage.

Happy to implement either in a follow-up once you pick.

Out of scope

  • Thunderbird / Outlook add-ons (mentioned in the issue scope): separate repos. The UsageWarning component and usage.ts utility are deliberately framework-light so an equivalent can be dropped into each addon in follow-up PRs.
  • Changing VITE_MAX_UPLOAD_SIZE to 5 GB and setting VITE_ROLLING_LIMIT to 5 GB — that's Upgrade max upload size to 5 GB with 5 GB per 2-week rolling limit #85.

How to verify

npm run check       # passes
npm run build       # passes
npm run dev         # then visit /fileshare
  • Drop two files totalling >5 GB → inline error banner appears under the file list.
  • Mock cryptify returning usage ≥3.3 GB at /usage?email=... → warning banner renders after typing a recipient email.
  • Mock cryptify returning 413 on upload → server-blocked banner renders instead of the error page.

Test plan

  • Interactive UI check once backend usage endpoint is reachable (cryptify#100 merged).
  • Confirm the sender-vs-recipient question above, then update the UsageWarning binding if needed.
  • Follow-up PRs in postguard-outlook-addon and postguard-tb-addon to reuse this component / utility.

Related issues

Closes #87.

- Shows a warning banner when a user has used ≥10 GB of the 15 GB
  rolling 2-week limit, and a hard-block banner at 15 GB.
- Shows an inline 'upload limit exceeded' error in the file picker
  when selected files total more than the per-upload (5 GB) limit,
  instead of surfacing it only at send time.
- Gracefully handles cryptify's 413 response (cryptify#100) with a
  clear server-blocked banner instead of the generic error page.
- Adds a VITE_ROLLING_LIMIT env constant with a 15 GB default, ready
  for postguard-website#85 to set it. Per-upload size text now
  derives from MAX_UPLOAD_SIZE instead of hard-coding '2 GB'.
- Adds usage utilities ($lib/usage.ts) and a UsageWarning component
  that can be reused by the Thunderbird/Outlook add-ons.

Proactive warning is currently wired to the first recipient email
because the fileshare UI has no sender email input — the usage quota
is per sender. See the PR body for the open design question.
@rubenhensen

Copy link
Copy Markdown
Contributor

I was mistaken with the proactive check. Check it as soon as you know the senders email.

@rubenhensen rubenhensen changed the title feat: warn users approaching upload limits and block at 5 GB / 15 GB feat: warn users approaching upload limits and block at 5 GB Apr 23, 2026
@rubenhensen

Copy link
Copy Markdown
Contributor

Superseded by #110 which combines this with #89 and #90.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show clear warnings and errors when approaching or hitting upload limits

1 participant