Skip to content

1.10.0

Choose a tag to compare

@goldnead goldnead released this 22 Sep 20:49
· 10 commits to main since this release

Fixed: the weekly digest arrived every week with nothing in it

The guard against an empty digest existed and sat in the right place, and it still let every
single weekly mail through. It asked whether there were any items and whether any source had
contributed something — and the bundled LeadHub source contributed the same thing forever. It
counted follow-ups that were overdue and not yet completed, which is a state, not an event. One
forgotten follow-up was therefore news again on Monday, and the Monday after that. The digest was
never empty, so it was never skipped, and what arrived was a mail whose body said "Nothing new
this time" and then printed {"leadhub":{"overdue_followups":2}} in a <pre> block underneath.

Both halves are fixed, because either one alone still leaves a broken mail. A source is now handed
the end of the last digest this recipient actually received, and counts only what became overdue
since then — read from the existing notification_digest_runs rows, so there is no new column and
no migration. And what reaches the mail is a finished sentence under a new line key, so the
template has something to print rather than something to encode.

Anything without a line now contributes nothing — not a row in the body, and not a reason to
send the digest at all. That is the general form of the fix and the part that matters most: a
source this package has never heard of can no longer force an empty mail out of the door by
reporting a permanent state. It is also what keeps the change safe. DigestSource::collect() still
returns array and still takes the same three arguments, so a source written against the older
shape keeps loading and keeps running. It simply stops contributing until it says something in
words. Narrowing the return type instead would have been a compile-time fatal in every
implementation in the field, unreachable by any try/catch here, and it would have taken the
whole digest run down with it.

Second argument names what it always should have: $since, the end of the last digest, not the
start of the window. A source that ignores it and reports everything currently open brings the
original bug back with it.

The placeholder line also stops arguing with the rest of the mail: "Nothing new this time" now
appears only when the sources have nothing either.

Fixed: and no second mail that says exactly what the first one said

Empty is not the only way to have nothing to report. A source that answers with a state — three
open tasks, four upcoming events — has content every week and news only sometimes, and the window
check cannot tell those apart, because every window is new. The result is a mail that arrives every
Monday listing the same three tasks. It has content. It reports nothing.

So a digest is now also compared against what this recipient was last actually sent. Word for word
the same, and it does not go. The run reports it: Skipped: 0 empty, 1 unchanged since the last one, ….

The comparison is a SHA-256 over what the digest says — the items it carries and the sentence
each source wrote — never over the rendered mail. A hash of the HTML would tie the guarantee to the
template, and changing a colour would post one more empty-handed digest to everybody.

Items go in by id, not by their wording. Two separate mentions read identically ("hat dich
erwähnt.") and are not the same news; collapsing them would silence a real notification, which is
worse than the bug being fixed here. So a digest that carries any item at all is always new, and
what this gate really catches is the case it was built for: sources alone, repeating themselves.

The fingerprint is written only after a mail has really been delivered. A run that was recorded
and then failed to send leaves it untouched, so a broken sender identity cannot swallow the next
real digest on top of everything else it already costs.

New column notification_digest_runs.content_fingerprint, nullable, filled from the moment a
digest is delivered. php artisan migrate adds it; installs that never send a digest never fill
it.

Also fixed on the way past: notifications:send-digests kept its count of undelivered digests
between invocations. One process per run on a cron, so it never showed there — but anything calling
the command twice in one process reported the second, healthy run as failed.

A published view keeps working. $extras is still keyed by source handle and still holds
whatever that source returned, so a copy of
resources/views/vendor/notifications/mail/digest.blade.php that reaches into the payload — the
way adriangoldner.com builds its event list — needs no change at all. Only the shipped fallback
was rewritten, from the json_encode() block to the source's own sentence. If your copy still
holds that block, {{ $extra['line'] }} replaces it.