A mail is a subject and a body in markdown, with {placeholders}
filled from the case. Portal writes it in the same write as the move
that sends it, so a mail exists exactly when its move does; gdo
delivers it, and a reply comes back as a note on the case.
What sends mail:
- a state, as a case arrives there (State machines);
- an invite, in portal’s words or the content’s (
invite: { group, mail },mail.invitein site.yaml); - a page naming someone responsible, telling them so;
- a suggested change, as it moves.
Variables
A placeholder is { letters, digits, _, - or . }. One that
names nothing renders as nothing; a brace that opens no name stays a
brace. The variables come in layers, so a template written for one
kind of mail reads the same in another.
On every mail
{site} | the instance’s public URL, no trailing slash |
{site_name} | site.yaml’s title |
On a mail about a record (every state mail)
{field} | any field of the record, as the form sent it |
{chain} | the record’s id |
{email} | the record’s email field, trimmed |
{bucket}, {state} | where it is and the state it just entered |
{machine.name} | a field of the record a type: record field points at: a booking’s machine, a reply’s notice |
{self_link} | the record’s own page for the person it belongs to: a page offering a self-service move (self_transition) on the bucket from the state the record is in, with the ?chain=&email= that lets them act without signing in. Empty when there is no such page or no address |
{link} | where this reader acts: {self_link} in a mail to: submitter; in one to anyone else, the page whose list over the bucket has transitions (else one that reads it); and {site} when there is neither |
{payment_url} | on a state with payment: only: where the person pays, the link the money service gave, else {self_link}. With a service, a mail that says it waits until the service says the request is out (State machines) |
{link} is the one to reach for. “See the report and book a visit:
{link}” sent to the caretaker opens the desk the report is on; “The
fault you reported is fixed. {link}” sent to the tenant opens their own
case where they can still act on it, or the site when there is
nothing left for them to do.
On a mail about a place on a board (a places bucket)
{ics_link} | the person’s own calendar of their places on the board |
{slot.field} | through the type: record field naming the thing, as above: {shift.what}, {shift.start} |
On a notice (notice: on a bucket; see State machines),
beside every field of the notice: {name} (the recipient’s),
{audience} (the audience’s label) and {unsubscribe_link} (empty on
a mandatory notice). Portal adds the window and the way out (or the
word that it cannot be stopped) under the body itself, so neither can
be left out.
On an invite and the note to someone responsible, beside every
field of the invite’s form: {name}, {username}, {email},
{group} (invite, the group as a person reads it: Medlemmer, or the
content’s own label, not the name in aggregates.yaml), {questions} (responsible), {expires},
{link}, which here is the one-time sign-in link, and {handbook}
(invite): the link to the group’s handbook, /handbook/<group>.
Portal’s own words for an invite into a group end by pointing to
that handbook, which the group reads once signed in (A manual for
the people who run the site). Words the
content writes carry it where they name {handbook}.
An invite with no group has no {group} to fill. Its own mail is
refused if it names one or leaves out {link}; site.yaml’s
mail.invite is used if it fits and otherwise left for portal’s own
words, which speak of the account alone. Someone who already has an
account gets a line telling them to sign in, as there is no link to
give.
A field a form asks for with type: prosekit holds HTML. Named in a
mail’s body, it goes in the HTML part as written, cleaned against the same
allow-list a list uses, and in the plain part as readable text: blocks
apart, a list as a list, a link with where it goes. In a subject, as text.
The same goes for one on a record it points at, {notice.text}.
A calendar entry
A mail about a time carries it, so it lands in the reader’s calendar:
confirmed:
event: confirmed
mail:
to: submitter
subject: "Your {machine.name}, {from} to {until}"
body: "The {machine.name} is yours from {from} to {until}."
event: { start: from, end: until, title: "{machine.name}", location: "{machine.where}" }
start and end name fields of the record: a type: date is a whole
day, a type: datetime-local a time in the site’s timezone. Portal
puts the event on the message as the person meant it, one per record
and state; gdo turns it into an invite the reader’s mail client offers
to add (a text/calendar part), and, where it has a calendar of the
site’s own, writes it there too. The mail says which, so nobody wonders
whether a calendar got it. A gdo from before events sends the mail as
before, without the entry.
What the lint holds a mail to
A state mail that sends from a state no record reaches warns; one that
names a field no form recording into the bucket collects fails, since
it would go out with a blank where the field should be. The lint
knows every variable above, so {link} and the rest are never
flagged. to: submitter requires a required email on every form
filling the bucket, and to: "{notice.email}" requires the notice
field. An event: requires its start on every such form, required,
as type: date or type: datetime-local, and its end likewise
where one is named; the two may not be the same field.