1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Emails.AdminEmail do
6 @moduledoc "Admin emails"
11 alias Pleroma.Web.Router.Helpers
13 defp instance_config, do: Pleroma.Config.get(:instance)
14 defp instance_name, do: instance_config()[:name]
16 defp instance_notify_email do
17 Keyword.get(instance_config(), :notify_email, instance_config()[:email])
20 defp user_url(user) do
21 Helpers.user_feed_url(Pleroma.Web.Endpoint, :feed_redirect, user.id)
24 def test_email(mail_to \\ nil) do
26 <h3>Instance Test Email</h3>
27 <p>A test email was requested. Hello. :)</p>
31 |> to(mail_to || Config.get([:instance, :email]))
32 |> from({instance_name(), instance_notify_email()})
33 |> subject("Instance Test Email")
34 |> html_body(html_body)
37 def report(to, reporter, account, statuses, comment) do
40 "<p>Comment: #{comment}"
46 if is_list(statuses) && length(statuses) > 0 do
51 status_url = Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, id)
52 "<li><a href=\"#{status_url}\">#{status_url}</li>"
54 id when is_binary(id) ->
55 "<li><a href=\"#{id}\">#{id}</li>"
71 <p>Reported by: <a href="#{user_url(reporter)}">#{reporter.nickname}</a></p>
72 <p>Reported Account: <a href="#{user_url(account)}">#{account.nickname}</a></p>
78 |> to({to.name, to.email})
79 |> from({instance_name(), instance_notify_email()})
80 |> subject("#{instance_name()} Report")
81 |> html_body(html_body)