feat: customer e-mails in the Site's look, and an order confirmation
All checks were successful
Build and deploy / Validate source (push) Successful in 49s
Build and deploy / Integration suite on a real stack (push) Successful in 3m23s
Build and deploy / Secret scan and release gate (push) Successful in 10s
Build and deploy / Publish images (push) Successful in 1m17s

The account e-mails (signup and e-mail change codes, new password, an
address that already has an account, the changed-e-mail notice) gain an
HTML version beside their plain text: the DROPSTAR header, a white card,
orange buttons, the customer greeted by first name. Built with tables and
inline styles only, so Gmail, Outlook and phone apps show it the same.

A paid order now also e-mails the customer "Recebemos seu pedido #N": the
items, delivery and total, the stages to come, and a link to the order in
the account. Not for an operator's test order. A code's or a recovery
link's HTML is erased with its text once sent. The team's alerts stay plain
text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-19 09:18:20 -03:00
parent 5910d3161f
commit 3879754397
8 changed files with 359 additions and 42 deletions

View File

@@ -276,6 +276,9 @@ CREATE TABLE IF NOT EXISTS dtf_local.mail_queue (
created_at timestamptz NOT NULL DEFAULT now(), available_at timestamptz NOT NULL DEFAULT now(),
attempts int NOT NULL DEFAULT 0, last_error text, sent_at timestamptz, failed_at timestamptz
);
-- The HTML version of a customer message (app/mail_html.py); erased with the
-- text for a code or a recovery link.
ALTER TABLE dtf_local.mail_queue ADD COLUMN IF NOT EXISTS html text;
CREATE INDEX IF NOT EXISTS mail_queue_pending ON dtf_local.mail_queue(available_at, id)
WHERE sent_at IS NULL AND failed_at IS NULL;
-- A customer's password recovery: only the token's hash is kept, for an hour,
@@ -321,9 +324,10 @@ UPDATE dtf_local.accounts a SET email_verified=true WHERE NOT a.email_verified A
OR EXISTS (SELECT 1 FROM dtf_local.mail_queue m WHERE m.kind='code' AND lower(m.to_addr)=a.email
AND m.created_at<=a.created_at));
-- E-mail kinds: a password-recovery link, a code, the notice that an account
-- already exists, the notice of a changed e-mail, the team's alerts and a test.
-- already exists, the notice of a changed e-mail, a customer's paid order,
-- the team's alerts and a test.
-- Defined once, here: the schema runs on every start, and an earlier, narrower
-- copy would refuse the rows of the kinds added after it.
ALTER TABLE dtf_local.mail_queue DROP CONSTRAINT IF EXISTS mail_queue_kind_check;
ALTER TABLE dtf_local.mail_queue ADD CONSTRAINT mail_queue_kind_check
CHECK(kind IN ('reset','code','account','notice','alert','test'));
CHECK(kind IN ('reset','code','account','notice','order','alert','test'));