added welcome email
This commit is contained in:
parent
1b82b7eac9
commit
3edaecae96
12 changed files with 213 additions and 31 deletions
|
|
@ -12,17 +12,22 @@ defmodule Pleroma.Emails.UserEmail do
|
|||
alias Pleroma.Web.Endpoint
|
||||
alias Pleroma.Web.Router
|
||||
|
||||
defp instance_name, do: Config.get([:instance, :name])
|
||||
|
||||
defp sender do
|
||||
email = Config.get([:instance, :notify_email]) || Config.get([:instance, :email])
|
||||
{instance_name(), email}
|
||||
end
|
||||
import Pleroma.Config.Helpers, only: [instance_name: 0, sender: 0]
|
||||
|
||||
defp recipient(email, nil), do: email
|
||||
defp recipient(email, name), do: {name, email}
|
||||
defp recipient(%User{} = user), do: recipient(user.email, user.name)
|
||||
|
||||
@spec welcome(User.t(), map()) :: Swoosh.Email.t()
|
||||
def welcome(user, opts \\ %{}) do
|
||||
new()
|
||||
|> to(recipient(user))
|
||||
|> from(Map.get(opts, :sender, sender()))
|
||||
|> subject(Map.get(opts, :subject, "Welcome to #{instance_name()}!"))
|
||||
|> html_body(Map.get(opts, :html, "Welcome to #{instance_name()}!"))
|
||||
|> text_body(Map.get(opts, :text, "Welcome to #{instance_name()}!"))
|
||||
end
|
||||
|
||||
def password_reset_email(user, token) when is_binary(token) do
|
||||
password_reset_url = Router.Helpers.reset_password_url(Endpoint, :reset, token)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue