Improve digest email template
This commit is contained in:
parent
29807ef6a5
commit
4b7f1c6995
5 changed files with 602 additions and 20 deletions
|
|
@ -123,6 +123,11 @@ defmodule Pleroma.Emails.UserEmail do
|
|||
end)
|
||||
|
||||
with [_ | _] = mentions <- new_notifications.mentions do
|
||||
mentions =
|
||||
Enum.map(mentions, fn mention ->
|
||||
update_in(mention.object.data["content"], &format_links/1)
|
||||
end)
|
||||
|
||||
html_data = %{
|
||||
instance: instance_name(),
|
||||
user: user,
|
||||
|
|
@ -131,17 +136,29 @@ defmodule Pleroma.Emails.UserEmail do
|
|||
unsubscribe_link: unsubscribe_url(user, "digest")
|
||||
}
|
||||
|
||||
logo_path = Path.join(:code.priv_dir(:pleroma), "static/static/logo.png")
|
||||
|
||||
new()
|
||||
|> to(recipient(user))
|
||||
|> from(sender())
|
||||
|> subject("Your digest from #{instance_name()}")
|
||||
|> put_layout(false)
|
||||
|> render_body("digest.html", html_data)
|
||||
|> attachment(Swoosh.Attachment.new(logo_path, filename: "logo.png", type: :inline))
|
||||
else
|
||||
_ ->
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
defp format_links(str) do
|
||||
re = ~r/<a.+href=['"].*>/iU
|
||||
|
||||
String.replace(str, re, fn link ->
|
||||
String.replace(link, "<a", "<a style=\"color: #d8a070;text-decoration: none;\"")
|
||||
end)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Generate unsubscribe link for given user and notifications type.
|
||||
The link contains JWT token with the data, and subscription can be modified without
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue