From b3c5395cfc7ac74be0fb6f00214bc711c0ff5944 Mon Sep 17 00:00:00 2001 From: ngqile Date: Mon, 30 Nov 2026 12:05:21 +0800 Subject: [PATCH] docs: email listing workaround and its SQL in the handover; tick change tasks Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM --- docs/deployment.md | 8 +++++++- openspec/changes/add-admin-email-listing/design.md | 4 ++-- openspec/changes/add-admin-email-listing/tasks.md | 10 +++++----- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/docs/deployment.md b/docs/deployment.md index 173522d..eeb37a9 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -69,6 +69,12 @@ The Service names matter: read -rs PW; printf '%s' "$PW" | docker run --rm -i httpd:2.4-alpine htpasswd -inBC 10 "" | tr -d ':\n'; unset PW ``` +**Later SQL, after the package, in this order:** + +| File | What it does | +|---|---| +| `openspec/changes/archive/2026-11-30-add-admin-email-listing/sql/01-email-module.sql` | Adds the Emails back-office module (`BO_EMAILS`). | + After running `04`, `SELECT LENGTH(password) FROM \`service-system\`.\`user\` WHERE id = 1;` must return 60. The administrator signs in as `admin` and must set a new password before anything else. **Database user:** @@ -257,7 +263,7 @@ data: ## 10. Known gaps at go-live -- **No email provider yet.** Staff onboarding does not need one: the admin types each new user's first password, and "Set temporary password" on a user's page unlocks a user who forgot theirs. Both force a password change at the next sign-in. Forgot-password and "Send password reset" do send email, so they do not work until a provider is configured in `service-email`. +- **No email provider yet.** Staff onboarding does not need one: the admin types each new user's first password, and "Set temporary password" on a user's page unlocks a user who forgot theirs. Both force a password change at the next sign-in. Forgot-password and "Send password reset" still create an email with a temporary password. Nobody receives it, but `service-email` saves every email first, so a super admin (or a role granted Emails) can read it under **Emails** and pass the password on in person. The user must change it at the next sign-in. Grant Emails narrowly: it shows every saved email, including other users' temporary passwords. - **Reference data from Tastefully.** It still holds some Tastefully business text (message templates with a phone number, bank account and form links; a public image bucket URL; Tastefully usernames in audit columns). Review it before go-live. - **Other Tastefully defaults.** The sender addresses in `service-email` and the `CUSTOMER_PORTAL_BASE_URL` fallback point at Tastefully. Override them as described in section 6. - **Leaked SMS key.** An SMS360 API key from Tastefully was in `service-email`'s config and is in git history. It has been removed from the config, but it must be rotated with SMS360 before go-live, by whoever owns that Tastefully account. diff --git a/openspec/changes/add-admin-email-listing/design.md b/openspec/changes/add-admin-email-listing/design.md index 55704c5..eced65b 100644 --- a/openspec/changes/add-admin-email-listing/design.md +++ b/openspec/changes/add-admin-email-listing/design.md @@ -4,7 +4,7 @@ - **Storage:** `service-email`'s `/email/send` saves the email (subject, body, recipients, status) before it publishes it for sending. Every email is in `service-email`.`email`, with its recipients in `recipient`, whether or not a provider delivered it. - **Existing queries in service-email:** - - `/email/findByPropertyAndPageable` takes `{property, pageableRest}`. The supported properties are `id`, `sender`, `subject`, `recipient` (a join, matched with like) and `startDate`/`endDate` (dd/MM/yyyy). + - `/email/findByPropertyAndPageable` takes `{property, pageableRest}`. The supported properties are `id`, `sender`, `subject`, `recipient` (a join, matched with like) and `startDate`/`endDate` (dd-MM-yyyy, the `system.dateformat` in core-libs). - `/email/findById/{id}` returns the email with its body and recipients, or an empty body when there is none. - **Who sends password emails:** services-system's `resetAdminPassword` (admin reset and admin forgot-password) and the member password paths. - **Access model:** `@AdminModule` on mobile-api handlers. A super admin (role id 1) passes every module check and sees every menu entry. The portal menu comes from the `module` table (`url`, `icon_name`). @@ -25,7 +25,7 @@ 1. **mobile-api `AdminEmailController`** (`@AdminModule("BO_EMAILS")`, `@AppAuth`), backed by `AdminEmailService`. - **`GET /api/admin/emails?recipient&subject&from&to&page&size`** - It calls `/email/findByPropertyAndPageable` with only the properties that were given, sorted by `datetime` descending. - - `from` and `to` arrive as `yyyy-MM-dd` and are converted to service-email's `dd/MM/yyyy`. + - `from` and `to` arrive as `yyyy-MM-dd` and are converted to service-email's `dd-MM-yyyy`. - Each row maps to `{id, datetime, recipients: [address], subject, status}`. The body is dropped here and never leaves mobile-api in the list. - **`GET /api/admin/emails/{id}`** - It calls `/email/findById/{id}`. An empty body gives 404 `EMAIL_NOT_FOUND`. diff --git a/openspec/changes/add-admin-email-listing/tasks.md b/openspec/changes/add-admin-email-listing/tasks.md index 67599e0..f97ba7d 100644 --- a/openspec/changes/add-admin-email-listing/tasks.md +++ b/openspec/changes/add-admin-email-listing/tasks.md @@ -4,7 +4,7 @@ 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. +- [x] 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/**` @@ -12,12 +12,12 @@ Design: `design.md`. All tasks run serially: each builds on the one before. ## 2. Backend -- [ ] 2.1 mobile-api `AdminEmailController` and `AdminEmailService` (design decision 1). +- [x] 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; + - `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:** @@ -39,7 +39,7 @@ Design: `design.md`. All tasks run serially: each builds on the one before. ## 3. Portal -- [ ] 3.1 `/emails` list and `/emails/[id]` detail (design decision 2): proxy routes, a service and i18n keys. +- [x] 3.1 `/emails` list and `/emails/[id]` detail (design decision 2): proxy routes, a service and i18n keys. Tests first: - **List:** @@ -59,7 +59,7 @@ Design: `design.md`. All tasks run serially: each builds on the one before. ## 4. Check and docs -- [ ] 4.1 Browser check and handover. +- [x] 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;