Commit Graph
3 Commits
Author SHA1 Message Date
grabowski 62a37b677a Anchor: each run ends its transaction itself
CI / secret scan (push) Successful in 6s
CI / fmt, clippy, tests (push) Successful in 1m18s
CI / release (push) Skipped
A run that was not due dropped its transaction, and sqlx rolls a dropped
one back only when the connection is returned, from a background task.
Until then the advisory lock stays taken, so a run right after it (the
test's next call on a busy CI runner; on the server a tick that comes at
the wrong moment) found the lock taken and skipped. Every way out of
run_daily now rolls back explicitly (sending happens on the pool; the
transaction only holds the lock). The test checks from a connection of
its own that no lock is left after a run that sent nothing.
2026-11-23 00:31:51 +07:00
grabowski 72a4faf71a Phase 11, step 2: the journal's daily anchor by mail
CI / secret scan (push) Successful in 7s
CI / fmt, clippy, tests (push) Successful in 50s
CI / release (push) Canceled after 34s
Every day from 07:00 Chiang Mai time the app mails the journal's last
entry number and its hash to the addresses set on the Notifications page
(src/anchor.rs, migration 0012: settings, journal_anchors), when anything
was added since the last anchor that went out. A day without news is
noted without a mail; a failed send is tried again after an hour; a
transaction-level advisory lock keeps two runs from both sending. "Send
the anchor now" sends at once. Each mail says whether the chain checked
whole (in capitals when it did not) and links to /journal/anchor, which
compares a kept entry number and hash with the journal now: the same
hash, another one, or no such entry. Changing the recipients is itself a
journal entry. Every anchor mail is in the notifications log.

Tests: the daily rule (before seven, once a day, an hour after a
failure), recipients checked and journaled, one mail per recipient with
the head hash, unchanged days, by hand, the check page's three answers,
and a chain broken around the app said in the mail. 126 unit, 67
integration.
2026-11-22 23:02:20 +07:00
grabowski 2e465a463c Phase 8 begins: mail, the Notifications page and a test mail
CI / secret scan (push) Successful in 8s
CI / fmt, clippy, tests (push) Successful in 1m50s
CI / release (push) Skipped
The app sends mail by SMTP submission (src/mail.rs, lettre over rustls
with the system's CA bundle, ring as reqwest): VISA_SMTP_HOST, _PORT
(465), _SECURITY (tls, starttls, or none for a server on this machine),
_USER and the password from VISA_SMTP_PASSWORD_FILE or the credential
smtp-password; VISA_MAIL_FROM defaults to "Lanna Desk <user>",
VISA_MAIL_REPLY_TO is optional. Without VISA_SMTP_HOST mail is off. The
settings are checked at start; the password stays out of Debug.

The Notifications page (Office) shows the sender, server and connection,
sends a test mail to the address given (offered again next time) and
shows the mail server's answer; every message sent or failed is logged
(notifications, migration 0011). Text messages say "not yet".

Tests: a fake SMTP server checks the envelope, Subject and Reply-To, a
refused recipient logged as failed, a bad address and mail switched off.
121 unit, 65 integration.
2026-11-22 22:18:02 +07:00