aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/emails/user_email.ex21
-rw-r--r--lib/pleroma/web/twitter_api/twitter_api_controller.ex10
2 files changed, 31 insertions, 0 deletions
diff --git a/lib/pleroma/emails/user_email.ex b/lib/pleroma/emails/user_email.ex
index 9cdf002f3..47dcd42e0 100644
--- a/lib/pleroma/emails/user_email.ex
+++ b/lib/pleroma/emails/user_email.ex
@@ -37,4 +37,25 @@ defmodule Pleroma.UserEmail do
|> subject("Password reset")
|> html_body(html_body)
end
+
+ def user_invitation_email(user, to_email, to_name \\ nil) do
+ registration_url =
+ Router.Helpers.redirect_url(
+ Endpoint,
+ :registration_page,
+ ""
+ )
+
+ html_body = """
+ <h3>You are invited to #{instance_name()}</h3>
+ <p>#{user.name} invites you to join #{instance_name()}, an instance of Pleroma federated social networking platform.</p>
+ <p>Click the following link to register: <a href="#{registration_url}">accept invitation</a>.</p>
+ """
+
+ new()
+ |> to(recipient(to_email, to_name))
+ |> from(sender())
+ |> subject("Invitation to #{instance_name()}")
+ |> html_body(html_body)
+ end
end
diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex
index 38eff8191..d51d71299 100644
--- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex
+++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex
@@ -333,6 +333,16 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
end
end
+ def confirm_email(_conn, _params), do: :noop
+
+ def email_invite(%{assigns: %{user: user}} = conn, %{"email" => email} = params) do
+ with true <- Pleroma.Config.get([:instance, :invites_enabled]),
+ email <- Pleroma.UserEmail.user_invitation_email(user, email, params["name"]),
+ {:ok, _} <- Pleroma.Mailer.deliver(email) do
+ json_response(conn, :no_content, "")
+ end
+ end
+
def update_avatar(%{assigns: %{user: user}} = conn, params) do
{:ok, object} = ActivityPub.upload(params, type: :avatar)
change = Changeset.change(user, %{avatar: object.data})