Chime.Links (Chime v0.1.0-dev)

Copy Markdown View Source

Links that open a notification from an email or a channel, and read it in the feed: the same notification is read everywhere.

def email(data, _recipient, notification) do
  Swoosh.Email.new(subject: "New comment")
  |> Swoosh.Email.html_body(~s(<a href="#{Chime.link(notification, "/stories/#{data["story_id"]}")}">Read it</a>))
end

Chime.link/2 gives an address of chime_mail (the config's :mail_url), signed, that says the notification, its person and where to go. Opened, it marks the notification read (and seen) and its time in :clicked_at, tells the person's open pages, and redirects. The address is in the token, so the link cannot be made to send anyone elsewhere; a path goes on the config's :url. The :email channel gives each email the link of the notification's feed :url too, as assigns.link.

An unknown or forged token is a 404.