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.
94 lines
5.4 KiB
HTML
94 lines
5.4 KiB
HTML
{% extends "base.html" %}
|
|
{% import "_fields.html" as fm %}
|
|
{% block main %}
|
|
<div class="pagehead"><h1>Notifications</h1></div>
|
|
<p class="meta">How the back office reaches the team and the clients. Every message it sends, or fails to send, is in the log below.</p>
|
|
{% if result %}
|
|
<section class="card {% if result.status == "sent" %}okcard{% else %}warncard{% endif %}" id="result">
|
|
<header><h2>{% if result.status == "sent" %}The test mail went out{% else %}The test mail did not go out{% endif %}</h2></header>
|
|
<p>{% if result.status == "sent" %}The mail server took the mail for <b>{{ result.recipient }}</b>. Check that inbox, and its spam folder the first time.{% else %}To <b>{{ result.recipient }}</b>: the mail server or the connection refused it.{% endif %}</p>
|
|
<p class="muted small mono hashline">{{ result.detail }}</p>
|
|
</section>
|
|
{% endif %}
|
|
<div class="cols">
|
|
<section class="card" id="email">
|
|
<header><h2>Email</h2>{% if mail %}<span class="chip ok">set up</span>{% else %}<span class="chip warn">not set up</span>{% endif %}</header>
|
|
{% if mail %}
|
|
<dl class="kv">
|
|
<dt>Sent as</dt><dd>{{ mail.from }}</dd>
|
|
{% if mail.reply_to %}<dt>Replies go to</dt><dd>{{ mail.reply_to }}</dd>{% endif %}
|
|
<dt>Mail server</dt><dd class="mono">{{ mail.server }}</dd>
|
|
<dt>Connection</dt><dd>{{ mail.security }}</dd>
|
|
</dl>
|
|
<form method="post" action="/notifications/test-email" class="form" id="test-email-form">
|
|
<input type="hidden" name="csrf" value="{{ csrf }}">
|
|
<div class="grid">
|
|
{{ fm.text("to", "Send a test to", address, err=error, req=true, type="email", cls="wide", ph="you@example.com", hint="One address. The mail says who sent the test and when.") }}
|
|
</div>
|
|
<div class="formactions"><button type="submit" class="btn pri" id="send-test">Send a test email</button></div>
|
|
</form>
|
|
{% else %}
|
|
<p>This server has no mail server set. On the fleet, the app sends as <b>reminders@lannadesk.com</b> through mail.lannadesk.com once its password is passed to the service.</p>
|
|
{% if error %}<p class="err">{{ error }}</p>{% endif %}
|
|
{% endif %}
|
|
</section>
|
|
<section class="card" id="sms">
|
|
<header><h2>Text messages</h2><span class="chip plain">not yet</span></header>
|
|
<p>A provider for text messages to Thai and foreign numbers is being chosen. Reminders go by email first.</p>
|
|
</section>
|
|
</div>
|
|
<section class="card" id="anchor">
|
|
<header><h2>The journal's daily anchor</h2>{% if anchor_to %}<span class="chip ok">on</span>{% else %}<span class="chip warn">nobody set</span>{% endif %}</header>
|
|
<p class="hint lead">Every day from {{ anchor_hour }}:00 Chiang Mai time, the journal's last entry number and its hash go by mail to the addresses below, when something was added since the last one. Kept outside the server, those mails show later that nobody rebuilt the journal. Each mail links to <a href="/journal/anchor">Check an anchor</a>.</p>
|
|
{% if anchor_done %}<p class="notice ok" role="status" id="anchor-done">{{ anchor_done }}</p>{% endif %}
|
|
<form method="post" action="/notifications/anchor-to" class="form" id="anchor-to-form">
|
|
<input type="hidden" name="csrf" value="{{ csrf }}">
|
|
<div class="grid">
|
|
{{ fm.text("anchor_to", "Send it to", anchor_to, err=anchor_error, cls="wide", ph="lead@example.com, notary@example.com", hint="Addresses outside this server, separated by commas: a partner, the firm's lead, an archive mailbox elsewhere. Changes go into the journal.") }}
|
|
</div>
|
|
<div class="formactions">
|
|
<button type="submit" class="btn" id="save-anchor-to">Save</button>
|
|
{% if mail and anchor_to %}<button type="submit" class="btn pri" id="anchor-now" formaction="/notifications/anchor-now">Send the anchor now</button>{% endif %}
|
|
</div>
|
|
</form>
|
|
{% if anchors %}
|
|
<div class="tblwrap">
|
|
<table class="tbl" id="anchor-log">
|
|
<thead><tr><th>Day</th><th>Entry and hash</th><th>How it went</th></tr></thead>
|
|
<tbody>
|
|
{% for a in anchors %}
|
|
<tr>
|
|
<td class="nowrap">{{ a.day }}<div class="sub">{{ a.how }}, {{ a.at }}</div></td>
|
|
<td><b>{{ a.seq }}</b> <span class="mono small" title="{{ a.hash }}">{{ a.hash[:16] }}…</span>{% if not a.whole %} <span class="chip bad">chain broken</span>{% endif %}</td>
|
|
<td><span class="chip {% if a.status == "sent" %}ok{% elif a.status == "unchanged" %}plain{% else %}bad{% endif %}">{{ a.status }}</span>{% if a.recipients %}<div class="sub">{{ a.recipients }}</div>{% endif %}</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{% endif %}
|
|
</section>
|
|
<h2 class="sechead" id="log">Log</h2>
|
|
{% if log %}
|
|
<div class="card flush">
|
|
<div class="tblwrap">
|
|
<table class="tbl" id="notification-log">
|
|
<thead><tr><th>When</th><th>To</th><th>What</th><th>How it went</th></tr></thead>
|
|
<tbody>
|
|
{% for l in log %}
|
|
<tr id="n-{{ l.id }}">
|
|
<td class="nowrap">{{ l.at }}<div class="sub">{{ l.actor }}</div></td>
|
|
<td>{{ l.recipient }}<div class="sub">{{ l.channel }}</div></td>
|
|
<td>{{ l.subject }}<div class="sub">{{ l.purpose }}</div></td>
|
|
<td><span class="chip {% if l.status == "sent" %}ok{% else %}bad{% endif %}">{{ l.status }}</span><div class="sub mono">{{ l.detail[:120] }}</div></td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
{% else %}
|
|
<p class="empty-inline">Nothing sent yet.</p>
|
|
{% endif %}
|
|
{% endblock %}
|