Repository navigation
feat(portal): email order confirmations and withdrawal receipts - #615
Conversation
The portal must itself confirm an order on a durable medium (Consumer Contracts Act, section 13) and acknowledge a withdrawal (section 20 a); until now the operator did this by hand. It now uses the site's existing send-only SES sender (platform#5400). - internal/mail is a small SMTP submission client: STARTTLS before any credential, a verified certificate, PLAIN after TLS, a fixed sender, UTF-8 plain text, and errors that carry no address or content. - Placing an order queues its confirmation, and a withdrawal its receipt, in the same transaction (portal_mail_outbox, migration v23), once per order and kind, in the client's language, to their contact address. The confirmation restates the order, the early-start request or the first day work may begin, the last day to withdraw and the terms. - One replica sends the queue every minute under an advisory lock, shared with the invoice sync, and records each delivery once. The operator's page shows each email as queued or sent. - The sender starts only when the projected credential files are configured. Orders and withdrawals stay behind the billing gates. Part of #21 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codex review for Portal email: the SMTP client's STARTTLS-before-AUTH and certificate checks, header injection, queuing in the order and withdrawal transactions, the one-replica send loop and delivery records, migration v23 and its role check, and that no address or body reaches logs or errors |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 98309075db
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
✅MegaLinter analysis: Success
See detailed reports in MegaLinter artifacts Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining
|
Code coverage overviewLanguages: Go Go / code-coverage/go
Line coverage data for the main branch is not yet available. View coverage of the 10 most covered files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
Codex review on #615: - The send loop now sends nothing while the portal's identity gate is closed, and checks the gate again before each email, so closing the portal stops delivery. - The order confirmation now also restates the accepted deliverables, in both languages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codex review for Re-review: the mail loop stops while the identity gate is closed, and the order confirmation includes the accepted deliverables |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |

What
Two Danish-law items blocked switching the portal on. The portal must itself email an order confirmation (Consumer Contracts Act, section 13) and a withdrawal receipt (section 20 a) on a durable medium. Until now the operator did this by hand. This PR sends both through the site's existing send-only SES sender (devantler-tech/platform#5400): no new sender.
internal/mail. A small SMTP submission client for that sender.no-reply@devantler.techonly.portal_mail_outbox, migration v23). Each is queued once per order and kind, in the client's language, to the client's contact address. A retry or a repeated withdrawal queues nothing more. A client without a contact address gets nothing, and the operator's page says so.RunMailsends the queue every minute under an advisory lock, the same one-replica pattern as the invoice sync, now a sharedwithRunLock. It sends nothing while the portal's identity gate is closed, and it checks the gate again before each email, so closing the portal stops delivery. It records each delivery once (portal_mail_deliveries). A failure stops the pass and is tried again on the next one; a message whose delivery record was lost may arrive twice.PORTAL_SMTP_USERNAME_FILEandPORTAL_SMTP_PASSWORD_FILEname the projected credential, both or neither.PORTAL_SMTP_ADDR(port 587 only; default the SES endpoint) andPORTAL_MAIL_FROM(defaultno-reply@devantler.tech) are optional, and all four are accepted from the settings projection. Without them nothing is sent, and orders and withdrawals only exist behind the false-default billing gates.Rollout
smtp-usernameandsmtp-passwordtobusiness-site-runtime, and SES egress on 587.SES is in its sandbox until AWS grants production access, so for now it delivers only to verified addresses.
Tests run locally (PostgreSQL 17, Go 1.27.4)
TestSendRequiresTLSAndAuthenticationruns against a fake SMTP server with real STARTTLS:TestSendRefusesWithoutTLSOrWithAWrongCredential:TestOrderAndWithdrawalAreConfirmedByEmail:TestOrderWithoutContactQueuesNoEmailandTestMailConfigIsOptionalAndStrict(plus the settings projection) cover the remaining paths.contactintegrationandcontacttrialintegration.Builds on #613, now merged. Part of #21
🤖 Generated with Claude Code