21096a7446b4cd01168d5069269c2b5daec3320e
[akkoma] / lib / pleroma / emails / new_users_digest_email.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 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 logo = Pleroma.Config.get([Pleroma.Emails.UserEmail, :logo])
16
17 logo_path =
18 if is_nil(logo) do
19 Path.join(:code.priv_dir(:pleroma), "static/static/logo.png")
20 else
21 Path.join(Pleroma.Config.get([:instance, :static_dir]), logo)
22 end
23
24 new()
25 |> to({to.name, to.email})
26 |> from({instance_name, instance_notify_email()})
27 |> subject("#{instance_name} New Users")
28 |> render_body("new_users_digest.html", %{
29 title: "New Users",
30 users_and_statuses: users_and_statuses,
31 instance: instance_name,
32 styling: styling
33 })
34 |> attachment(Swoosh.Attachment.new(logo_path, filename: "logo.png", type: :inline))
35 end
36 end