aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/emails/user_email.ex
diff options
context:
space:
mode:
authorEgor Kislitsyn <egor@kislitsyn.com>2019-08-14 20:46:05 +0700
committerEgor Kislitsyn <egor@kislitsyn.com>2019-08-14 20:46:05 +0700
commit4b7f1c6995ca49c782e3e29d14245f18d4d11430 (patch)
tree3287474c200d3347b567891313a09a86aec990d9 /lib/pleroma/emails/user_email.ex
parent29807ef6a5b43a528ffca08b4f721b251f331c8d (diff)
downloadpleroma-4b7f1c6995ca49c782e3e29d14245f18d4d11430.tar.gz
Improve digest email template
Diffstat (limited to 'lib/pleroma/emails/user_email.ex')
-rw-r--r--lib/pleroma/emails/user_email.ex17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/pleroma/emails/user_email.ex b/lib/pleroma/emails/user_email.ex
index 49046bb8b..bf6b811b1 100644
--- a/lib/pleroma/emails/user_email.ex
+++ b/lib/pleroma/emails/user_email.ex
@@ -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