Update/add OpenBSD config files
[akkoma] / lib / pleroma / emails / user_email.ex
1 defmodule Pleroma.UserEmail do
2 @moduledoc "User emails"
3
4 import Swoosh.Email
5
6 alias Pleroma.Web.{Endpoint, Router}
7
8 defp instance_config, do: Pleroma.Config.get(:instance)
9
10 defp instance_name, do: instance_config()[:name]
11
12 defp sender do
13 {instance_name(), instance_config()[:email]}
14 end
15
16 defp recipient(email, nil), do: email
17 defp recipient(email, name), do: {name, email}
18
19 def password_reset_email(user, password_reset_token) when is_binary(password_reset_token) do
20 password_reset_url =
21 Router.Helpers.util_url(
22 Endpoint,
23 :show_password_reset,
24 password_reset_token
25 )
26
27 html_body = """
28 <h3>Reset your password at #{instance_name()}</h3>
29 <p>Someone has requested password change for your account at #{instance_name()}.</p>
30 <p>If it was you, visit the following link to proceed: <a href="#{password_reset_url}">reset password</a>.</p>
31 <p>If it was someone else, nothing to worry about: your data is secure and your password has not been changed.</p>
32 """
33
34 new()
35 |> to(recipient(user.email, user.name))
36 |> from(sender())
37 |> subject("Password reset")
38 |> html_body(html_body)
39 end
40 end