1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Emails.AdminEmail do
6 @moduledoc "Admin emails"
12 alias Pleroma.Web.Router.Helpers
14 defp instance_config, do: Config.get(:instance)
15 defp instance_name, do: instance_config()[:name]
17 defp instance_notify_email do
18 Keyword.get(instance_config(), :notify_email, instance_config()[:email])
21 defp user_url(user) do
22 Helpers.user_feed_url(Pleroma.Web.Endpoint, :feed_redirect, user.id)
25 def test_email(mail_to \\ nil) do
27 <h3>Instance Test Email</h3>
28 <p>A test email was requested. Hello. :)</p>
32 |> to(mail_to || Config.get([:instance, :email]))
33 |> from({instance_name(), instance_notify_email()})
34 |> subject("Instance Test Email")
35 |> html_body(html_body)
38 def report(to, reporter, account, statuses, comment) do
41 "<p>Comment: #{comment}"
47 if is_list(statuses) && length(statuses) > 0 do
52 status_url = Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, id)
53 "<li><a href=\"#{status_url}\">#{status_url}</li>"
55 id when is_binary(id) ->
56 "<li><a href=\"#{id}\">#{id}</li>"
72 <p>Reported by: <a href="#{user_url(reporter)}">#{reporter.nickname}</a></p>
73 <p>Reported Account: <a href="#{user_url(account)}">#{account.nickname}</a></p>
77 <a href="#{Pleroma.Web.base_url()}/pleroma/admin/#/reports/index">View Reports in AdminFE</a>
81 |> to({to.name, to.email})
82 |> from({instance_name(), instance_notify_email()})
83 |> subject("#{instance_name()} Report")
84 |> html_body(html_body)
87 def new_unapproved_registration(to, account) do
89 <p>New account for review: <a href="#{user_url(account)}">@#{account.nickname}</a></p>
90 <blockquote>#{HTML.strip_tags(account.registration_reason)}</blockquote>
91 <a href="#{Pleroma.Web.base_url()}/pleroma/admin">Visit AdminFE</a>
95 |> to({to.name, to.email})
96 |> from({instance_name(), instance_notify_email()})
97 |> subject("New account up for review on #{instance_name()} (@#{account.nickname})")
98 |> html_body(html_body)