Skip to content

fix(reports): lock email-only options when mail isn't set up (#141) - #153

Merged
ibrahimroshdy merged 1 commit into
mainfrom
fix/email-lock
Oct 16, 2026
Merged

ibrahimroshdy merged 1 commit into
mainfrom
fix/email-lock

Conversation

@ibrahimroshdy

Copy link
Copy Markdown
Collaborator

Closes #141.

On a server without mail, Email it to me and Send it again in Print inventory looked like normal options: you could turn them on and nothing ever arrived. Now they're locked and say why, and the server refuses them too.

What a person sees

  • Mail not set up on the server: both options are disabled and dimmed, with a lock and the line "Email isn't set up on this server."
    • Instance admins, and owners and admins of the location, also get Set up email, which opens the docs' Mail page (/admin/notifications/#mail).
    • Everyone else reads "Ask the owner to set up email."
  • Account with no email address (a managed account): the same lock, with "Add an email address to your account."
  • Screen readers: the switch and the Send it again group are disabled, and aria-describedby points both at the lock line.
  • With mail set up, nothing changes.

How it works

  • Web: the sheet reads smtpConfigured from the notification settings it already had, plus /me for the address and the location list for the role. Until the settings load, nothing is locked; the server catches anything sent in that gap. A locked option is never put in the request.
  • Server: POST /api/v1/reports/inventory and /reports/insurance with email: true, and PUT /api/v1/me/report-schedules, now return 409 mail_not_configured when KEPT_SMTP_URL is unset, and 409 no_email_address when the account has no address it can send to. Before, these were accepted and the mail was dropped. Both codes are new in @kept/shared; the web shows each as one sentence.
  • An address that isn't verified yet is still accepted, as before.
  • The mock API refuses these requests the same way.

Audit of other email-only options

  • Invite → Send by email: already a disabled placeholder that says why (unchanged).
  • Settings → Notifications → Email channel: already says mail is off and hides Test.
  • Digests and alerts follow the channel. Exports, condition reports and move sheets never send mail.
  • Not covered: a schedule made while mail worked keeps running if mail is removed later. The run is made and the mail is logged as due.

Docs and spec

  • Users' "Reports" section and the admin Mail page say what is locked and why.
  • D254.

Tested

  • Server: src/reports/reports.test.ts adds two cases: mail off refuses email: true and a schedule while a plain report still runs; an account with no address is refused. The existing mail tests now run with mail configured.
  • Web: test/screens/reports.test.tsx adds six cases: mail on means nothing is locked; mail off as owner shows the lock, the description and the link, and the PDF still runs without email; a member gets "ask the owner"; no address; the server's refusal shown as a sentence; Arabic keeps to logical CSS.
  • ci-local.sh --only lint,typecheck,drift, check-i18n, check-logical-css, the full server suite.

Print inventory's Email it to me and Send it again are disabled, with a
lock and the reason under them, when the server has no mail or the
account has no address. Owners and admins get Set up email (the docs'
Mail page); others are told to ask the owner. The server refuses
email: true and report schedules with 409 mail_not_configured or
no_email_address instead of accepting them and dropping the mail (D254).

Closes #141

Signed-off-by: Ibrahim Roshdy <22573766+ibrahimroshdy@users.noreply.github.com>
@ibrahimroshdy
ibrahimroshdy merged commit aa82d5c into main Oct 16, 2026
21 checks passed
@ibrahimroshdy
ibrahimroshdy deleted the fix/email-lock branch October 16, 2026 15:13
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lock email-only options when mail isn't set up

1 participant