X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Femails%2Fuser_email.ex;h=856816386e89708815f7796c374d210cac0400a0;hb=1de0aa2f1025d4a860a11e658ce5fed26fe1c4ad;hp=46d8b9c2d65f26646855aff0967ea628f7b07afa;hpb=f5afb11032913fe523bd688954b4923f357c7802;p=akkoma diff --git a/lib/pleroma/emails/user_email.ex b/lib/pleroma/emails/user_email.ex index 46d8b9c2d..856816386 100644 --- a/lib/pleroma/emails/user_email.ex +++ b/lib/pleroma/emails/user_email.ex @@ -9,10 +9,14 @@ defmodule Pleroma.UserEmail do defp instance_name, do: instance_config()[:name] - defp from do + defp sender do {instance_name(), instance_config()[:email]} end + defp recipient(email, nil), do: email + defp recipient(email, name), do: {name, email} + defp recipient(%Pleroma.User{} = user), do: recipient(user.email, user.name) + def password_reset_email(user, password_reset_token) when is_binary(password_reset_token) do password_reset_url = Router.Helpers.util_url( @@ -29,9 +33,56 @@ defmodule Pleroma.UserEmail do """ new() - |> to({user.name, user.email}) - |> from(from()) + |> to(recipient(user)) + |> from(sender()) |> subject("Password reset") |> html_body(html_body) end + + def user_invitation_email( + user, + %Pleroma.UserInviteToken{} = user_invite_token, + to_email, + to_name \\ nil + ) do + registration_url = + Router.Helpers.redirect_url( + Endpoint, + :registration_page, + user_invite_token.token + ) + + html_body = """ +

You are invited to #{instance_name()}

+

#{user.name} invites you to join #{instance_name()}, an instance of Pleroma federated social networking platform.

+

Click the following link to register: accept invitation.

+ """ + + new() + |> to(recipient(to_email, to_name)) + |> from(sender()) + |> subject("Invitation to #{instance_name()}") + |> html_body(html_body) + end + + def account_confirmation_email(user) do + confirmation_url = + Router.Helpers.confirm_email_url( + Endpoint, + :confirm_email, + to_string(user.info.confirmation_token) + ) + + html_body = """ +

Welcome to #{instance_name()}!

+

Email confirmation is required to activate the account.

+

Click the following link to proceed: activate your account.

+ """ + + new() + |> to(recipient(user)) + |> from(sender()) + |> subject("#{instance_name()} account confirmation") + |> html_body(html_body) + end end