# Tasks Design: `design.md`. All tasks run serially: each builds on the one before. ## 1. Data - [ ] 1.1 Add the `BO_EMAILS` module row (design decision 3) to `local/seed/03-colite.sql`, and keep `sql/01-email-module.sql` in this change identical to it. - Apply the row to the running local database, a local-only, additive insert of the same statement. - Check that the admin's menu gets an Emails entry. - Scope: `local/seed/03-colite.sql`, `openspec/changes/add-admin-email-listing/sql/**` - Verify: the row is present (`select` on `module`), and `/api/admin/auth` menu data includes `/emails` for the super admin. ## 2. Backend - [ ] 2.1 mobile-api `AdminEmailController` and `AdminEmailService` (design decision 1). Tests first: - **List:** - it sends only the given properties, sorted by `datetime` descending; - `from` and `to` are converted to dd/MM/yyyy; - rows map to id, datetime, recipient addresses, subject and status; - no `body` key in any row. - **Detail:** - it returns the body and recipients; - an empty upstream body gives 404 `EMAIL_NOT_FOUND`; - a non-super caller and a super-admin recipient give 403 `SUPER_ADMIN_REQUIRED`; - a non-super caller and a non-super recipient succeed; - a super-admin caller skips the recipient lookup; - the audit line has the id and username but not the body. - **Controller:** class-level `@AdminModule("BO_EMAILS")`, and the endpoints map their parameters. Live check through the gateway as the dev admin: - trigger forgot-password for a made-up local admin; - list the emails, open that one, and read the password; - as a made-up non-super admin with `BO_EMAILS`, get 403 on an email to the super admin; - as `noevents` (no `BO_EMAILS`), get refused. - Scope: `solvway-mobile-api/src/**` (new admin email files, the email constants, tests) - Verify: `mvn -T 1C -B -q -pl solvway-mobile-api -am verify` ## 3. Portal - [ ] 3.1 `/emails` list and `/emails/[id]` detail (design decision 2): proxy routes, a service and i18n keys. Tests first: - **List:** - it renders the rows newest first; - the filters go into the query; - paging; - a row links to its detail. - **Detail:** - it shows the metadata; - the body is in an iframe with an empty `sandbox` and `srcDoc`, and not in the page DOM; - 404 shows not-found; - 403 shows the super-admin message. - **Proxy routes:** they forward the query and the id, and pass refusals through with their code. - **Module gate:** `RequireModule` gates both pages. - Scope: `solvway-admin-portal/app/emails/**`, `solvway-admin-portal/app/api/emails/**`, `solvway-admin-portal/app/lib/**` - Verify: `cd solvway-admin-portal && npx vitest run && npx tsc --noEmit && npm run lint && npm run build` ## 4. Check and docs - [ ] 4.1 Browser check and handover. - **Playwright on the local stack:** - as admin, trigger forgot-password for a made-up user; - open Emails, find it, open it, and read the password in the frame; - sign in with that password and get the forced change; - as a made-up non-super admin with `BO_EMAILS`, open an email to the super admin and see the refusal; - as `noevents`, see no Emails menu entry, and see Not authorized at `/emails`; - check both pages at 360px. - **Docs:** `docs/deployment.md` section 3 (the new SQL file) and section 10 (the workaround). - Scope: `docs/deployment.md` - Verify: screenshots, and the steps above observed. ## Workflow follow-up - Whole-branch review, push, PR to main and merge, then archive on its own branch.