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.
21 lines
913 B
SQL
21 lines
913 B
SQL
-- Lanna Desk, phase 8 begins: the notifications log (docs/PLAN.md "Phase 8").
|
|
--
|
|
-- Every mail the app sends, or fails to send, is a row here: the test from
|
|
-- the Notifications page first, the reminders later. A text message or a
|
|
-- Matrix message gets its own channel when those come.
|
|
|
|
CREATE TABLE notifications (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
channel TEXT NOT NULL CHECK (channel IN ('email', 'sms', 'matrix')),
|
|
-- what it was for: 'test', later 'reminder' ...
|
|
purpose TEXT NOT NULL CHECK (purpose <> ''),
|
|
recipient TEXT NOT NULL CHECK (recipient <> ''),
|
|
subject TEXT NOT NULL DEFAULT '',
|
|
status TEXT NOT NULL CHECK (status IN ('sent', 'failed')),
|
|
-- the mail server's answer, or why it failed
|
|
detail TEXT NOT NULL DEFAULT '',
|
|
actor TEXT NOT NULL,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
);
|
|
CREATE INDEX notifications_created ON notifications (created_at DESC);
|