Merge branch 'improve-og-embed' into 'develop'
[akkoma] / lib / pleroma / emails / new_users_digest_email.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Emails.NewUsersDigestEmail do
6 use Phoenix.Swoosh, view: Pleroma.Web.EmailView, layout: {Pleroma.Web.LayoutView, :email_styled}
7
8 defp instance_notify_email do
9 Pleroma.Config.get([:instance, :notify_email]) || Pleroma.Config.get([:instance, :email])
10 end
11
12 def new_users(to, users_and_statuses) do
13 instance_name = Pleroma.Config.get([:instance, :name])
14 styling = Pleroma.Config.get([Pleroma.Emails.UserEmail, :styling])
15
16 logo_url =
17 Pleroma.Helpers.UriHelper.maybe_add_base(
18 Pleroma.Config.get([:frontend_configurations, :pleroma_fe, :logo]),
19 Pleroma.Web.Endpoint.url()
20 )
21
22 new()
23 |> to({to.name, to.email})
24 |> from({instance_name, instance_notify_email()})
25 |> subject("#{instance_name} New Users")
26 |> render_body("new_users_digest.html", %{
27 title: "New Users",
28 users_and_statuses: users_and_statuses,
29 instance: instance_name,
30 styling: styling,
31 logo_url: logo_url
32 })
33 end
34 end