The digests: one email of the notifications of a day or a week, for the
people who chose "daily" or "weekly" for a category's email
(Chime.Preferences).
Such an email does not go at its time: its delivery waits, as
"digest", with the decisions of then made (the :unless and :if
of the notifier, the preferences). Every hour, a job finds the people
whose digest is due, in their own time zone (:time_zone of
Chime.Recipient): at the config's hour (:at of :digest, 9), every
day for a daily digest, on :weekly_on (Monday) for a weekly one. Each
person gets one email of all their notifications due, and each delivery
is then "digested". An hour the job missed (a deploy) is made up at
the next.
The time zones need a time zone database (tz or tzdata) set as
Elixir's: config :elixir, :time_zone_database, Tz.TimeZoneDatabase.
Without one, every digest is at the hour in UTC.
The email
Chime writes it from what the feed shows of each notification
(Chime.Notifier.feed/2), unless the app gives its own module
(email: MyApp.ChimeDigest in :digest):
defmodule MyApp.ChimeDigest do
import Swoosh.Email
def email(recipient, items, period) do
new()
|> subject("Your #{period} digest: #{length(items)} notifications")
|> html_body(MyAppWeb.Emails.digest(recipient: recipient, items: items))
end
endEach item is %{notification: %Chime.Notification{}, feed: %{title: ...}},
the newest first, and period is "daily" or "weekly" ("daily"
when both are due). Chime gives the email its To:, its From: and a
link to unsubscribe from every email that is not required.